第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

請(qǐng)問(wèn)怎么正確使用Vue.js的組件

請(qǐng)問(wèn)怎么正確使用Vue.js的組件

撒科打諢 2019-10-22 13:12:20
請(qǐng)問(wèn)怎么正確使用Vue.js的組件
查看完整描述

2 回答

?
人到中年有點(diǎn)甜

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊

  1. # 下載最新的vue$ npm install vue

  2. js 引用 vue.js

  3. 開(kāi)始代碼,感受vue強(qiáng)大的雙向數(shù)據(jù)綁定

1

2

3

4

5

6

7

8

9

10

11

<div id="app">

  <p>{{ message }}</p>

  <input v-model="message">

</div>

     

new Vue({

  el: '#app',

  data: {

    message: 'Hello Vue.js!'

  }

})

實(shí)戰(zhàn)代碼:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<div id="app">

  <input v-model="newTodo" v-on:keyup.enter="addTodo">

  <ul>

    <li v-for="todo in todos">

      <span>{{ todo.text }}</span>

      <button v-on:click="removeTodo($index)">X</button>

    </li>

  </ul>

</div>

     

new Vue({

  el: '#app',

  data: {

    newTodo: '',

    todos: [

      { text: 'Add some todos' }

    ]

  },

  methods: {

    addTodo: function () {

      var text = this.newTodo.trim()

      if (text) {

        this.todos.push({ text: text })

        this.newTodo = ''

      }

    },

    removeTodo: function (index) {

      this.todos.splice(index, 1)

    }

  }

})

Vue整個(gè)生命周期示意圖:



 




查看完整回答
反對(duì) 回復(fù) 2019-10-23
?
哈士奇WWW

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超6個(gè)贊

var vue = new Vue({

el: 'body',
data: {
//這里負(fù)責(zé)數(shù)據(jù)
myData: {},
},
ready: function () {
//這里是vue初始化完成后執(zhí)行的函數(shù)
this.test();
},
methods: {
//這里是自定義的方法
test: function () {
alert('test');
}
}

});

 




查看完整回答
反對(duì) 回復(fù) 2019-10-23
  • 2 回答
  • 0 關(guān)注
  • 466 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)