Then, how do you use the Vue method?
Here's how to define that method in our Vue instance:
- var vm = new Vue({
- el: '#example',
- name: 'Vue.js'
- // define methods under the `methods` object.
- greet: function (event) {
- // `this` inside methods point to the Vue instance.
- alert('Hello ' + this.name + '!' )
- // `event` is the native DOM event.
Beside above, how do I start Vue? Deploying the Vue sample app
- Navigate to the root folder of the application in the command line.
- Type npm install --global surge to install Surge on your computer.
- Type npm run build to build the application and make it production-ready.
- Type cd build to navigate to the build folder.
Moreover, how do I use onclick Vue?
Method Event Handlers
var example2 = new Vue({ el: '#example-2', data: { name: 'Vue. js' }, // define methods under the `methods` object methods: { greet: function (event) { // `this` inside methods points to the Vue instance alert('Hello ' + this.name + '!'
How do I use addEventListener Vue?
How to use the listener addEventListener in vue
- mounted () {
- this.$nextTick(() => {
- document.getElementById('id').addEventListener('your event', () => {
- })
- })
- }
