자바 스크립트를 추가하기 전까지 내 앱의 모든 것이 완벽하게 작동했습니다. 이제 콘솔에서 계속 오류가 발생합니다..vue 파일에 정의되지 않은 속성 또는 메서드
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.
뿐만 아니라이 오류 :
나는이 오류가
TypeError: _vm.show is not a function at click App.vue?d98c:25 at HTMLButtonElement.invoker vue.esm.js?efeb:1906
원하는 결과 : "loginBtn"를 클릭 경고 "클릭"메시지가 표시됩니다.
내 코드 :
// app.vue script
export default {
name: 'app'
}
var show = new Vue({
el: '#loginBtn',
data: {
n: 0
},
methods: {
show: function(event) {
targetId = event.currentTarget.id;
alert('click')
}
}
})
<!-- the button -->
<template>
<div>
<button v-on:click="show($event)" id="loginBtn">Login</button>
</div>
</template>
yayyy! Tysm, 몇 시간 동안 찾고 있었지만, 내가 생각하기에 이것을 달성하는 많은 방법이 있습니다. 또한, 내가 찾은 다른 사람들은 그것이 수출 내에서해야한다고 설명했는데, 대부분은 ('새로운 Vue')를 만들라고 말했습니다. – hannacreed
도와 줘서 기쁩니다! 그리고 네.'.vue' 파일은'vue-loader '가 ('새로운 Vue'를 통해 인스턴스화 할 필요가있는) 상용구 코드를 추상화하는 데 사용하는 특정 형식을 따릅니다. 내 게시물을 편집하여 도움이 될만한 문서를 링크했습니다. – thanksd