mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-21 22:09:16 +08:00
feat(vant-cli): 支持通过 vant.config.js 配置是否显示页面右侧的手机模拟器
This commit is contained in:
parent
336727556e
commit
3a900cdb7b
@ -6,6 +6,7 @@
|
||||
:config="config"
|
||||
:versions="versions"
|
||||
:simulator="simulator"
|
||||
:has-simulator="hasSimulator"
|
||||
:lang-configs="langConfigs"
|
||||
>
|
||||
<router-view />
|
||||
@ -28,6 +29,7 @@ export default {
|
||||
|
||||
return {
|
||||
simulator: `${path}mobile.html${location.hash}`,
|
||||
hasSimulator: true,
|
||||
};
|
||||
},
|
||||
|
||||
@ -63,18 +65,18 @@ export default {
|
||||
watch: {
|
||||
// eslint-disable-next-line
|
||||
'$route.path'() {
|
||||
this.setTitle();
|
||||
this.setTitleAndToogleSimulator();
|
||||
},
|
||||
|
||||
lang(val) {
|
||||
setLang(val);
|
||||
this.setTitle();
|
||||
this.setTitleAndToogleSimulator();
|
||||
},
|
||||
|
||||
config: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.setTitle();
|
||||
this.setTitleAndToogleSimulator();
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
@ -82,7 +84,7 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
setTitle() {
|
||||
setTitleAndToogleSimulator() {
|
||||
let { title } = this.config;
|
||||
|
||||
const navItems = this.config.nav.reduce(
|
||||
@ -101,6 +103,8 @@ export default {
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
|
||||
this.hasSimulator = !(current && current.hideSimulator);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -8,12 +8,12 @@
|
||||
@switch-version="$emit('switch-version', $event)"
|
||||
/>
|
||||
<doc-nav :lang="lang" :nav-config="config.nav" />
|
||||
<doc-container :has-simulator="!!simulator">
|
||||
<doc-container :has-simulator="hasSimulator">
|
||||
<doc-content>
|
||||
<slot />
|
||||
</doc-content>
|
||||
</doc-container>
|
||||
<doc-simulator v-if="simulator" :src="simulator" />
|
||||
<doc-simulator v-if="hasSimulator" :src="simulator" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -39,6 +39,7 @@ export default {
|
||||
lang: String,
|
||||
versions: Array,
|
||||
simulator: String,
|
||||
hasSimulator: Boolean,
|
||||
langConfigs: Array,
|
||||
config: {
|
||||
type: Object,
|
||||
|
Loading…
x
Reference in New Issue
Block a user