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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何正確使用Vue.js的組件

如何正確使用Vue.js的組件

紅糖糍粑 2019-03-03 04:04:23
如何正確使用Vue.js的組件
查看完整描述

2 回答

?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

陪伴而非守候

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

  2. js 引用 vue.js

  3. 開始代碼,感受vue強大的雙向數(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!'

  }

})

實戰(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整個生命周期示意圖:



 




查看完整回答
反對 回復 2019-03-11
?
慕森王

TA貢獻1777條經驗 獲得超3個贊

var vue = new Vue({

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

});

 




查看完整回答
反對 回復 2019-03-11
  • 2 回答
  • 0 關注
  • 639 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號