亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么的的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>


正在回答

3 回答

58653bd1000187e203730081.jpg

58653bd10001f73e03460380.jpg

58653bd20001ab8e02480063.jpg

  1. v-model的model你寫錯了

  2. 應該在data()里面加入newItem = '',參照1樓圖2的位置加入

  3. consle.log(this.newItem),括號里面應該為this.newItem,可以理解為調用data()里面的newItem的值


0 回復 有任何疑惑可以回復我~

http://img1.sycdn.imooc.com//57ac50e50001f1b405240159.jpg
是不是因為v-model寫錯了==

1 回復 有任何疑惑可以回復我~
#1

arlenhui

眼神刁鉆,可以
2016-08-13 回復 有任何疑惑可以回復我~

enter指的是輸入框輸入的值嗎?

如果是的話,那就獲取newItem就好了

在data里面注冊屬性

data?()?{
??????return?{
????????msg:?'Hellosss?Wrld!',
????????items:?[
??????????{
????????????label:?'coding',
????????????isFinished:?false
??????????},
??????????{
????????????label:?'playing',
????????????isFinished:?true
??????????}
????????],
????????newItem?:?''????????//注冊屬性
??????}
????}

然后在addNew事件里面直接可以打印出來看看

?methods:?{
??????toggleFinsih:?function?(item)?{
????????item.isFinished?=?!item.isFinished
??????},
??????addNew:?function?()?{
????????console.log(this.newItem);???????//打印屬性
??????}
????}


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
vue.js入門基礎
  • 參與學習       209639    人
  • 解答問題       715    個

本門為vuejs入門教程,詳細的講解加實戰,可以幫你進入vuejs的大門

進入課程

為什么的的enter值就是獲取不到 有獎問答 幫忙者有紅包多謝大神們

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號