provide,inject
程序员文章站
2022-05-14 15:54:16
...
<!--
* @Author: your name
* @Date: 2021-04-15 16:37:34
* @LastEditTime: 2021-04-18 14:11:39
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \fission\Vue3demo\index.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.7/vue.global.js"></script>
</head>
<body>
<div id="app"></div>
<script>
console.log(Vue)
// console.log(Vue.createAp().mount('#app'))
//作用域插槽
const app = Vue.createApp({
provide(){
return {
honsrt:'3234'
}
},
data() {
return {
isClick: 'Dajia'
}
},
mounted() {
// },3000)
},
methods: {
handleAsyncComponents() {
},
chandleClick() {
this.isClick = this.isClick == 'Dajia' ? 'liuying' : 'Dajia'
}
},
template: `
<div @click="handleAsyncComponents">
同步
<Children/>
<AsyncCompoents/>
</div>
`
})
app.component('AsyncCompoents', Vue.defineAsyncComponent(() => {
return new Promise((resole, reject) => {
setTimeout(() => {
resole({
inject:['honsrt'],
template: `Asnys组件{{honsrt}}`
})
}, 3000)
})
}))
app.component('Children', {
inject:['honsrt'],
data() {
return {
list: ['1', '2', '3']
}
},
template: `
{{honsrt}}
`
})
app.component('Dajia', {
template: `<h1>A</h1>`
})
app.component('liuying', {
template: `<h1>B</h1>`
})
app.mount('#app')
</script>
</body>
</html>
下一篇: Flutter定时器
推荐阅读
-
在vue中使用[provide/inject]实现页面reload
-
Flutter UI如何使用Provide实现主题切换详解
-
详解Vue实战指南之依赖注入(provide/inject)
-
谈VBS在Hacking中的作用———SQL Inject中的应用
-
Vue 2.0 中依赖注入 provide/inject组合实战
-
聊聊 Vue 中 provide/inject 的应用
-
ubuntu下进程kidle_inject致使编译软件很慢
-
Please provide a source image with `from` prior to commit
-
Please provide a source image with `from` prior to commit
-
zz Ruby迭代器each、map、collect、inject ruby