vue关于html页面id设置问题
vue是一个前端框架,类似于angularJS等,vue在编写的时候需要在html页面指定id,但是不是都可以实现的,一般放在id需在div设置里才可以实现。
(一)
在html里设置id:
<!DOCTYPE html>
<html id="vue">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div>
<h1>site : {{site}}</h1>
<h1>url : {{url}}</h1>
<h1>{{details()}}</h1>
</div>
<script type="text/javascript">
var vm = new Vue({
el: '#vue',
data: {
site: "菜鸟教程",
url: "www.runoob.com",
alexa: "10000"
},
methods: {
details: function() {
return this.site + " - 学的不仅是技术,更是梦想!";
}
}
})
</script>
</body>
</html>
页面效果:

可以看出并不起作用。
(二)
在body中设置id。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body id="vue">
<div>
<h1>site : {{site}}</h1>
<h1>url : {{url}}</h1>
<h1>{{details()}}</h1>
</div>
<script type="text/javascript">
var vm = new Vue({
el: '#vue',
data: {
site: "菜鸟教程",
url: "www.runoob.com",
alexa: "10000"
},
methods: {
details: function() {
return this.site + " - 学的不仅是技术,更是梦想!";
}
}
})
</script>
</body>
</html>
显示效果:

可以看出仍然是不起作用。
(三)
在div设置id:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div id="vue">
<h1>site : {{site}}</h1>
<h1>url : {{url}}</h1>
<h1>{{details()}}</h1>
</div>
<script type="text/javascript">
var vm = new Vue({
el: '#vue',
data: {
site: "菜鸟教程",
url: "www.runoob.com",
alexa: "10000"
},
methods: {
details: function() {
return this.site + " - 学的不仅是技术,更是梦想!";
}
}
})
</script>
</body>
</html>
效果展示:

可以看出现在已经正确渲染出来了。
结论:可以看出在html和body中设置id是不起作用的,应该是建一个div在里边设置id。
vue关于html页面id设置问题的更多相关文章
- WordPress后台的文章、分类,媒体,页面,评论,链接等所有信息中显示ID并将ID设置为第一列
WordPress后台默认是不显示文章.分类等信息ID的,查看起来非常不方便,不知道Wp团队出于什么原因默认不显示这个但可以使用Simply Show IDs插件来实现 不使用插件,其他网友的实现: ...
- vue webpack多页面构建
项目示例地址: https://github.com/ccyinghua/webpack-multipage 项目运行: 下载项目之后 # 下载依赖 npm install # 运行 npm run ...
- vue项目各页面间的传值
githut地址:https://github.com/liguoyong/vueobj1 一.父子之间主键传值:(主要是在父主件里的子主件传递参数,然后再子主件里用props接收) 例如Father ...
- 前端Vue项目——登录页面实现
一.geetest滑动验证 geetest官方文档地址:https://docs.geetest.com/ 产品——极速验证:基于深度学习的人机识别应用.极验「行为验证」是一项可以帮助你的网站与APP ...
- leyou_04_使用vue.js搭建页面—使用ajax完成品牌的查询
1.使用vue.js搭建页面 1.1使用的模板插件Vuetify 中文UI组件官网:https://vuetifyjs.com/zh-Hans/getting-started/quick-start ...
- 优化vue+springboot项目页面响应时间:waiting(TTFB) 及content Download
优化vue+springboot项目页面响应时间:waiting(TTFB) 及content Download TTFB全称Time To First Byte,是指网络请求被发起到从服务器接收到地 ...
- PHP 404页面/如何设置404页面/URL静态化/URL伪静态化
php中如何设置404页面及其他错误页面 首先在项目根目录下新建文件,文件名为" .htaccess " 在该文件中写入一下配置项: ErrorDocument 404 /404. ...
- vue获得当前页面URL动态拼接URL复制邀请链接方法
vue获得当前页面URL动态拼接URL复制邀请链接方法 当前页面完整url可以用 location.href路由路径可以用 this.$route.path路由路径参数 this.$route.par ...
- vue实现部分页面导入底部 vue配置公用头部、底部,可控制显示隐藏
vue实现部分页面导入底部 vue配置公用头部.底部,可控制显示隐藏 在app.vue文件里引入公共的header 和 footer header 和 footer 默认显示,例如某个页面不需要显示h ...
随机推荐
- SASS常用语法
原文地址:这里 @charset "UTF-8"; /** * 自定义变量 */ $blue: #1875e7; div { color: $blue; } /** * 变量要嵌在 ...
- hdoj:2033
#include <iostream> #include <string> using namespace std; int main() { int n; int h, m, ...
- 【Matplotlib】利用Python进行绘图
[Matplotlib] 教程:https://morvanzhou.github.io/tutorials/data-manipulation/plt/ 官方文档:https://matplotli ...
- 奇葩问题 eclipse中DDMS的LOGcat只有一列level
http://stackoverflow.com/questions/25010393/eclipse-logcat-shows-only-the-first-letter-from-each-mes ...
- Schema中elementFormDefault="qualified"所起的作用
有的xsd文件的开头是这样写的: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.or ...
- c# 正则匹配对称括号
https://stackoverflow.com/questions/7898310/using-regex-to-balance-match-parenthesis
- firadisk 把 win7(32位) 装入 VHD :仅仅支持内存模式:--mem
关键1:对于 win7(32位)来说,还可以在设备管理器内,通过添加“过时”硬件的方式导入wvblk驱动. 附件: grub4dos firadisk驱动
- [PyData] 02 - Data Preprocessing and Cleaning
From: DBWangGroup 基于该系列代码的实践与补充思考. 补充:特征工程 http://www.cnblogs.com/jasonfreak/category/823064.html & ...
- 一款Redis客户端,可以作为Redis Desktop manager的有效补充或替代
一.由来 对于redis客户端,我和大多数人一样,都是用Redis Desktop Manager. 但我发现个问题,我的版本是0.9.1.771. 我这个版本有个问题,就是如果value太长的话,不 ...
- nginx 自启动脚本
nginx 自启动脚本 创建脚本 cd /etc/init.d vi nginx 脚本如下: #! /bin/bash # chkconfig: 35 85 15 # description: Ngi ...