- Set the route
props
parameters - Use in the component
props
receivingparams
parameter
// Set as true
const router = new VueRouter({
routes: [{
path: '/user/:id',
component: User,
props: true
}]
})
// Back with a function
const router = new VueRouter({
routes: [{
path: '/user/:id',
component: User,
props: (route) => ({
id: route.query.id
})
}]
})
>>> .el-image {
}
/deep/ .el-image {
}
<input type="text" @input="inputHandler('hello', $event)" />
this.$emit('method', 'value')
<template>
<child @hook:mounted="listenMounted" />
</template>
emm … I have always put the ID of the listener in the data, but I just used it once when destroyed, so I can write it like this:
const timer = setInterval(method, 1000)
this.$once('hook:beforeDestroy', function () {
clearInterval(timer)
})
import Vue from 'vue'
import Message from './Message.vue'
// Constructor class
let MessageConstructor = Vue.extend(Message)
// instantiated components
let messageInstance = new MessageConstructor()
// $ Mount can be passed into the selector string, indicating that it is mounted to the selector
// If the selector is not passed into the element outside the document, you can imagine the document.createElement () to generate DOM in memory
messageInstance.$mount()
// MessageInstance. $ EL Get the DOM element
document.body.appendChild(messageInstance.$el)