项目作者: posrix

项目描述 :
A Vue mixin to sync props to data in real-time
高级语言: JavaScript
项目地址: git://github.com/posrix/vue-dynamic-props.git
创建时间: 2017-06-17T15:36:25Z
项目社区:https://github.com/posrix/vue-dynamic-props

开源协议:MIT License

下载


A Vue mixin to sync props to data in real-time

Real-time sync props to data. Useful when props receive async data that would change from time to time, and you also would like to mutate them rather than simply render them but to avoid the Vue warning.

Install

  1. yarn add vue-dynamic-props --dev

or npm

  1. npm install vue-dynamic-props --save-dev

Usage

Use default data key

  1. <template>
  2. <ul class="shopping-list">
  3. <li v-for="item in dynamicProps.items">
  4. {{ item }}
  5. </li>
  6. <ul></ul>
  7. </template>
  8. <script>
  9. import dynamicProps from 'vue-dynamic-props'
  10. export default {
  11. mixins: [
  12. dynamicProps()
  13. ],
  14. props: {
  15. items: Array
  16. }
  17. }
  18. </script>

Use a specified data key

  1. <template>
  2. <ul class="shopping-list">
  3. <li v-for="item in yourKey.items">
  4. {{ item }}
  5. </li>
  6. <ul></ul>
  7. </template>
  8. <script>
  9. import dynamicProps from 'vue-dynamic-props'
  10. export default {
  11. mixins: [
  12. dynamicProps('yourKey')
  13. ],
  14. props: {
  15. items: Array
  16. }
  17. }
  18. </script>

License

The MIT License (MIT). Please see License File for more information.