feat(vant-cli): 支持通过 vant.config.js 配置是否显示页面右侧的手机模拟器

This commit is contained in:
HaoChuan9421
2021-03-15 00:24:13 +08:00
parent 336727556e
commit 3a900cdb7b
2 changed files with 11 additions and 6 deletions
+8 -4
View File
@@ -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);
},
},
};