為什么的的enter值就是獲取不到 有獎問答 幫忙者有紅包多謝大神們
? <template>
? ? <div id="app">
? ? ? ? <h1 v-text="msg">{{msg}}</h1>
? ? ? ? <input v-modle="newItem" v-on:keyup.enter="addNew">
? ? </div>
? ? <ul>
? ? ? ? ? <li v-for="item in items" v-bind:class="{finished: item.isFinished}" v-on:click="toggleFinsih(item)">
? ? ? ? ? ? {{item.label}}
? ? ? ? ? </li>
? ? </ul>
? </template>
? <script>
? export default {
? ? data () {
? ? ? return {
? ? ? // note: changing this line won't causes changes
? ? ? // with hot-reload because the reloaded component
? ? ? // preserves its current state and we are modifying
? ? ? // its initial state.
? ? ? ? msg: 'Hellosss Wrld!',
? ? ? ? items: [
? ? ? ? ? {
? ? ? ? ? ? label: 'coding',
? ? ? ? ? ? isFinished: false
? ? ? ? ? },
? ? ? ? ? {
? ? ? ? ? ? label: 'playing',
? ? ? ? ? ? isFinished: true
? ? ? ? ? }
? ? ? ? ]
? ? ? }
? ? },
? ? methods: {
? ? ? toggleFinsih: function (item) {
? ? ? ? item.isFinished = !item.isFinished
? ? ? },
? ? ? addNew: function () {
? ? ? ? console.log(this)
? ? ? }
? ? }
? }
? </script>
? <style>
? .finished{
? ? text-decoration: underline;
? }
? </style>
2016-12-30
v-model的model你寫錯了
應該在data()里面加入newItem = '',參照1樓圖2的位置加入
consle.log(this.newItem),括號里面應該為this.newItem,可以理解為調用data()里面的newItem的值
2016-08-11
是不是因為v-model寫錯了==
2016-08-09
enter指的是輸入框輸入的值嗎?
如果是的話,那就獲取newItem就好了
在data里面注冊屬性
然后在addNew事件里面直接可以打印出來看看