Blogger Information
Blog 77
fans 0
comment 2
visits 55688
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue 中的 .sync 修饰符stop修饰符prevent修饰符可以press.enter修饰符
南瓜又个梦
Original
784 people have browsed it

sync

1,是一个语法糖
2,处理组件中数据与外部数据的交互,
因为外部数据不可以只用一部修改完成

  1. <template>
  2. <div class="child">
  3. {{money}}
  4. <button @click="$emit('update:money', money-100)">
  5. <span>花钱</span>
  6. </button>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. props: ["money"]
  12. };
  13. </script>
  14. <style>
  15. .child {
  16. border: 3px solid green;
  17. }
  18. </style>
  19. //这是子组件里的代码
  1. <template>
  2. <div class="app">
  3. App.vue 我现在有 {{total}}
  4. <hr>
  5. <Child :money.sync="total"/>
  6. </div>
  7. </template>
  8. <script>
  9. import Child from "./Child.vue";
  10. export default {
  11. data() {
  12. return { total: 10000 };
  13. },
  14. components: { Child: Child }
  15. };
  16. </script>
  17. <style>
  18. .app {
  19. border: 3px solid red;
  20. padding: 10px;
  21. }
  22. </style>
  23. //这是父组件的来源

注意看数据的流动

stop

是一个阻止默认事件发生的修饰符

prevent

是一个阻止冒泡的事件的修饰符。

press.enter

一个键盘事件的修饰符,要记得键盘按键的编码

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post