App.vue
main.js
<template>
<h2>Example methods Option</h2>
<p>Using the 'toggleMsg' method inside the methods option to toggle a message:</p>
<button v-on:click="toggleMsg">Toggle Message</button>
<pre v-show="showMsg">{{ msg }}</pre>
</template>
<script>
export default {
data() {
return {
msg: 'Hello World!',
showMsg: false
};
},
methods: {
toggleMsg() {
this.showMsg = !this.showMsg;
}
}
};
</script>
<style>
pre {
background-color: lightgreen;
}
</style>
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
app.mount('#app')