我开始在Vue中使用Parcel,但是有些奇怪。我有一个非常简单的应用程序,其中包含一些事件侦听器,但是它们都不起作用。这是我的代码:
package.json
{
"name": "fcf-ratings-ui","version": "1.0.0","main": "main.js","license": "MIT","dependencies": {
"vue": "^2.6.10","vuetify": "^2.1.9"
},"devDependencies": {
"parcel-bundler": "^1.12.4"
},"scripts": {
"start": "parcel app/*","watch": "parcel watch app/*","build": "parcel build app/*"
}
}
main.js
import Vue from "vue";
import App from "./AppTest.vue";
new Vue(App).$mount('#fcf-ratings-wrapper')
AppTest.vue
<template>
<div>
<pre>{{ showMsg }}</pre>
<button @click="showMsg = !showMsg">Show Message</button>
<p v-if="showMsg">This is the message</p>
</div>
</template>
<script>
export default {
name: "App",data: function() {
return {
showMsg: false,}
}
}
</script>
@click
事件应该可以工作,但是由于某种原因,它根本无法工作。通过代码正确设置了DOM,但是事件没有触发。
关于可能是什么原因的任何想法?