Vue 使用 httpVueLoader 加载vue组件 vue页面使用 module.exports
index.html
"en"> "UTF-8">游戏资源管理系统 "stylesheet" href="{$__TMPL__}/home/index/static/css/element_ui_index.css"> "stylesheet" href="{$__TMPL__}/home/index/static/css/iconfont.css"> "stylesheet" href="{$__TMPL__}/home/index/static/css/common.css">"app" v-cloak>if="isLogin"> class="left">"{$__TMPL__}/home/index/static/images/logo.png" class="logo">
class="right">"handleCommand"> class="el-dropdown-link">
"{$__TMPL__}/home/index/static/images/header.png" class="head_img"> 你好,{{userInfo.username}} class="iconfont icon-xiala">
"dropdown"> "login">退出登录 "140px"> default-active="1-4-1" class="el-menu-vertical-demo" :collapse="hideSider"> "changeMain(item.tag)" :class="{'is-active':currentComponent == item.tag}" v-for="(item ,index) in menuList" :key="index"> class="iconfont" :class="item.icon"> "title">{{item.name}} class="breadcrumb">"/"> "{ path: '/' }">首页 for="(item ,index) in menuList" :key="index" v-show="currentComponent == item.tag"> {{item.name}} is="currentComponent"> else> is="currentComponent">
index.js
// 使用httpVueLoader
new Vue({
el: '#app',
data() {
return {
visible: false,
hideSider: false,
currentComponent: "Login",
menuList: [
{
name: "文件上传",
tag: "FileUpload",
icon: "icon-upload_file"
},
{
name: "文件分类",
tag: "DocumentClassification",
icon: "icon-files"
},
{
name: "资源管理",
tag: "ResourceManager",
icon: "icon-resource"
},
{
name: "注册审核",
tag: "RegisterReview",
icon: "icon-regist"
}
],
userInfo: {
username: "张三"
},
isLogin: false,
}
},
components: {
'FileUpload': httpVueLoader('/template/default/pc/home/index/views/fileUpload.vue'),
'DocumentClassification': httpVueLoader('/template/default/pc/home/index/views/documentClassification.vue'),
'Login': httpVueLoader('/template/default/pc/home/index/views/login.vue'),
'RegisterReview': httpVueLoader('/template/default/pc/home/index/views/registerReview.vue'),
'ResourceManager': httpVueLoader('/template/default/pc/home/index/views/resourceManager.vue')
},
created() {
let _this = this;
_this.userInfo = getSessionStorage('userInfo');
console.log('userInfo', _this.userInfo);
if (!_this.userInfo) {
_this.isLogin = false;
_this.currentComponent = "Login";
} else {
console.log("已登录");
_this.isLogin = true;
_this.currentComponent = "FileUpload";
}
},
mounted() {
console.log("登录状态", this.isLogin);
},
watch: {
isLogin: function (val) {
let _this = this;
_this.isLogin = val;
}
},
methods: {
changeMain(obj) {
let _this = this;
_this.currentComponent = obj;
},
handleCommand(command) {
let _this = this;
this.$confirm('退出登录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
setSessionStorage('userInfo', '');
_this.isLogin = false;
_this.currentComponent = "Login";
}).catch(() => {
this.$message({
type: 'info',
message: '已取消退出'
});
});
}
}
})
login.vue
class="login-box" :class="{'register_box':!formStatus}">
class="left">
"/template/default/pc/home/index/static/images/login-k.png" alt="">
class="right">
"ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
class="login-title">Hello,
if="formStatus">欢迎登录!
else>欢迎注册!
"username">
"ruleForm.username" prefix-icon="el-icon-user" placeholder="请输入用户名">
if="!formStatus">
"email">
"ruleForm.email" prefix-icon="el-icon-message" placeholder="请输入邮箱">
"nickname">
"ruleForm.nickname" prefix-icon="el-icon-news" placeholder="请输入昵称">
"password">
"ruleForm.password" prefix-icon="el-icon-lock" placeholder="请输入密码" show-password>
class="right_item">
"goRegister">
if="formStatus">没有账号?点击注册
else>已有账号?点击登录
"primary" v-if="formStatus" @click="LoginForm('ruleForm')" class="login-btn-r">登录
"primary" v-else @click="registerForm('ruleForm')" class="login-btn-r">注册
"resetForm('ruleForm')">重置
本地访问没问题,但是发布到线上服务器时 火狐浏览器一直报错如下所示:并且没有找到解决办法
IE也不支持
若是有同行知道解决办法还请告知下哦,感激不尽