vue.js - 如何使我的自定义 CSS 和 Javascript 文件在我的 vuejs 应用程序中工作
问题描述
正在开发一个项目,在我的 vuejs 应用程序中,我注意到如果我应该导航到带有参数的路由,我的 index.html 中的 CSS 和我的 javascript 将不包括在内,它会在控制台中给我这个错误
Uncaught SyntaxError: Unexpected token <
这是我的路由器代码
import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home.vue";
Vue.use(Router);
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [
{
path: "/",
name: "home",
component: Home
},
{
path: '/profile/:id/',
name: 'Profile',
secure: true,
component: () =>
import(/* webpackChunkName: "Profile" */ "./components/slots/Users/profile.vue")
},
{
path: '*',
component: () =>
import(/* webpackChunkName: "404" */ "./components/slots/404.vue")
}
]
});
如果我应该去个人资料路线,我的 css 和 javascript 工作但如果我应该将其更改为
{
path: '/profile/',
name: 'Profile',
secure: true,
component: () =>
import(/* webpackChunkName: "Profile" */ "./components/slots/Users/profile.vue")
},
我的 css 和我的 javascript 将重新开始工作
这是我的 index.html 代码
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>CyberSec</title>
<link rel="shortcut icon" href="assets/ico/favicon.ico">
<link rel="stylesheet" type="text/css" href="assets/css/theme.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<noscript>
<strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
</body>
<script type="text/javascript" src="assets/plugins/jquery/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="assets/js/theme.js"></script>
</html>
请问我该如何解决这个问题或者我做错了什么
解决方案
推荐阅读
- javascript - Vue/Nuxt - 从一个 vue 插件观察/计算数组的长度
- android - 更改 firebase 安全角色
- javascript - 使 webpack(Nuxt 项目)选择“模块”而不是“主”
- laravel - API 凭证应该存储在 laravel 中的哪个位置?
- reinforcement-learning - 如何查看 OpenAI 健身房环境中可用的操作?
- jquery - 使用 jQuery AJAX 调用新值并将新值附加到新行
- node.js - AWS Lambda 使用 nodejs 脚本创建 rds 备份 -AWS RDS 和 SQL Server
- python - 强制导入模块的特定加载顺序
- node.js - Watson Assistant 对话框 - 子节点未出现在 WhatsApp 集成机器人中
- c - sprintf - 堆栈关系 - bufferoverflow