Sri*_*mam 15 vue.js vue-component
我有一个组件需要mixin取决于它收到的道具.
const timerMixin = {
created() {
console.log("Timer mixin injected")
}
}
export default {
name: 'Component A',
props: ['hasTimer'],
mixins: this.hasTimer ? [timerMixin] : [] // fails because `this` is not available here
}
Run Code Online (Sandbox Code Playgroud)
有没有办法动态地将mixin注入组件?
| 归档时间: |
|
| 查看次数: |
5087 次 |
| 最近记录: |