使用 uni-simple-router
main.js 代码如下
import Vue from 'vue'
import App from './App'
import store from './store'
Vue.config.productionTip = false
//import https://www.antdv.com/docs/vue/introduce-cn/
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css';
Vue.use(Antd)
//import global config
import config from '@/config.js'
Vue.prototype.$config = config
//import global mixin
import global from './mixins/global.js'
Vue.mixin( global )
// 引入uni-simple-router 详见:http://hhyang.cn/
import router from './router'
import {RouterMount} from 'uni-simple-router';
App.mpType = 'app'
const app = new Vue({
store,
render: h => h(App)
})
app.$mount()
// #ifdef H5
RouterMount(app,'#app');
// #endif
index.html代码更改为
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>
WOS管理系统
</title>
<link rel="shortcut icon" href="/static/images/favicon.ico" type="image/x-icon" />
<script>
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports(
'top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.min.css">
<link rel="stylesheet" href="/static/css/general.css">
</head>
<body>
<div id="app">
<div class="loading_init">
<img src="/static/images/logo-100.png">
</div>
</div>
</body>
</html>
运行页面空白 提示:Cannot find element: #app