這樣寫有問題嗎
<!DOCTYPE?html><html><head> <title></title> <script?src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script></head><body> <div?id="root"> <div?v-on:click="handleClick">{{msg}}</div> </div> <script?type="text/javascript"> new?Vue({ el?:?"#root", data?:?{ msg?:?"hello" }, methods?:?{ handleClick?:?function?()?{ this.msg?:?"world" } } }) </script></body></html>
把methods刪掉就很正常,不知道為什么
2018-08-16
應(yīng)該是 this.msg='world'? ?你把等號(hào)打成了冒號(hào)吧
2018-08-06
我覺得沒有問題,你可以嘗試運(yùn)行一下,看看效果。