Vue.js超初心者です。Vue.jsを勉強しています。
[Vue warn]: Property or method "show" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. とエラーが出ました。
htmlに
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>Vue.js App</title> <link href="main.css" rel="stylesheet"> </head> <body> <div id="app"> <button v-on:click="handleClick($event,item)">クリック</button> <img src="img.jpg" v-on:load="show=true" v-bind:class="{hide: !show}"> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script> <script src="main.js"></script> </body> </html>
と書き、cssに
img { opacity: 1; transition: opacity 1s; } img.hide{ opacity: 0; }
main.jsに
var app = new Vue({ el:'#app', data:{ list:[ {id:1,name:'スライム',hp:100}, {id:2,name:'ゴブリン',hp:200}, {id:3,name:'ドラゴン',hp:500},] }, methods:{ doAttack:function(index){ this.list[index].hp -=10 } } })
と書きました。クリックボタンを押すと、
画像がふわっと浮かび上がるシステムを作りたいのですが、上記のエラーが出ました。どう修正したらいいでしょうか?
エスパー検定試験ですか?なぜJavaScriptでエラーが出ているのにJavaScriptのソースを提示しないまま修正についての質問をするのでしょうか?あなたの書いたソースを見ずに透視(千里眼かあるいはほかの何かかもしれない)能力が使える人でも募集したいのでしょうか?
回答1件
あなたの回答
tips
プレビュー