- Plugin definition
// plugin 插件, 也是把通用性的功能封装起来
const myPlugin = {
//一定是一个install方法
install(app, options) {
//第一个参数app是一个vue实例,第二个这个实例的属性
console.log(app,options)
//外部传递进来的变量
console.log(name)
//提供一个number属性
app.provide('number', '123');
//给全局挂载一个sayHello属性
app.config.globalProperties.$sayHello = 'hello world';
}
}
- Use definition
app.use(myPlugin, {
name: '456'});
<teleport to="#box">
<div>222</div>
</teleport>
render() {
const {
h } = Vue;
return h(标签名, {
属性}, [内容])
}
- The portal
is to transfer the label to a certain label
<teleport to=".out">
<div class="inner">inner</div>
</teleport>
- render function
render() {
const {
h } = Vue;
return h(标签名, {
标签属性}, [标签内容])
}