my index.js code
import Vue from "vue";
import App from "./App.vue";
import VueRouter from "vue-router";
import routers from "./routers";
Vue.use(VueRouter);
const router = new VueRouter({
routers
});
let div = document.createElement("div");
div.id = "app";
document.body.appendChild(div);
new Vue({
router,
render: h => h(App)
}).$mount("-sharpapp");
my app.vue code
<template>
<div>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "app",
mounted() {
window.addEventListener("resize", this.handleResize);
this.handleResize();
},
beforeDestroy() {
window.removeEventListener("resize", this.handleResize);
},
methods: {
handleResize() {
var w = document.documentElement.clientWidth;
document.getElementsByTagName("html")[0].style["font-size"] = Math.min((w / 10).toFixed(1), 540 / 10) + "px";
}
}
}
</script>
roters.js Code
//
const HomePage = resolve => require(["./pages/index.vue"], resolve);
export default [
{
name: "index",
path: "/index",
components: HomePage
}
]
my folder structure
router.js
dom
the following is the git
warehouse address of my project
https://github.com/wustzhaohui/blog.git