Vue 实现了一套内容分发的 API,这套 API 的设计灵感源自 Web Components 规范草案,将 元素作为承载分发内容的出口。
内容过滤
### parent.vue
<titleVue>{{ title }}</titleVue>
### titleVue.vue
<h3>{{ title }}</h3>
computed:{
title() {
//此处对内容进行过滤
const name = this.$slots.default[0].text;
if (this.$route.query.brole === '1') {
return name;
} else {
return name.replace('该单位', '');
}
}
}