javascript - 如何在 Vue CDN 和 Vue-router CDN 中使用 html 模板?
问题描述
我有个问题。我正在为大学做一个软件项目,但他们希望我们使用 python。javascript 前端是允许的,因为这是针对非 CompSci 人员或程序员的特殊课程,即使我决定使用 CDN 版本的 vue 和 vue-router 来避免 npm、node 等,以使他们更容易。
所以现在我在 index.html 中定义了我的路由,在所有内容下方定义的脚本标记内,
<script src="views/dashboard/dashboard.js"></script>
<script src="views/input/input.js"></script>
<script src="views/info/info.js"></script>
<script src="views/settings/settings.js"></script>
const routes = [
{ path: '/', component: Dashboard },
{ path: '/input', component: Inputpage },
{ path: '/info', component: Infopage },
{ path: '/settings', component: Settingspage },
{ path: '/index.html', redirect: '/' } //default route. Leave this as such to
];
和 Dashboard/Inputpage/.. 等是我导入的 .js 文件。例如,Info.js 看起来像这样
var Infopage = {
template: '<h1>This page is for information</h1>'
};
这显示得很好。但是,当我添加任何其他内容(如 ap)或更简单的内容(如第二个标题、段落或输入)时,什么也没有发生。我能做些什么让它显示的不仅仅是一个标题?
编辑1:我试过
var Infopage = {
template:`<div id='info_page'>
<h1>This page is for information</h1>
</div>`
};
现在我收到错误 [Vue warn]: Error in nextTick: "InvalidCharacterError: String contains an invalid character"。
解决方案
推荐阅读
- django - django用户个人资料上传图片
- python - 有减少MultiIndex的功能吗?
- git - 如何在新计算机上设置 GIT,使用服务器中使用的相同 ssh 密钥进行连接
- python - 如何在 ndarray 中创建一个球体?
- c# - 获取重复对象的列表,包括所有出现的 C#
- javascript - 使用 webpack 在 Laravel 5 中将插件安装到 CKEditor 5
- ansible - 通过 Jenkins ansible playbook 将地图传递给 ansible
- batch-file - 为什么批处理文件意味着将文件备份到启动文件夹复制所有 System32 文件
- ios - ios如何快速更改不同视图控制器中另一个视图控制器的内容
- raku - 导出动态范围的变量?