1.key属性只能使用number或string类型
2.v-html , v-text:
v-html会解析字符串中的标签,而v-text不会.
3.过滤器的使用:
过滤器函数中的第一个参数只能是data(要传过来的数据)
具体使用:
//html中 {{msg|msgFormat('替换参数')}}//msg可以不用传
```
filters:{
msgFormat:(msg,param)=>{
return msg.replace(/a/g,param)
}
}
```
padStart的使用:
var newDate = 5.toString().padStart(2,'0')//es6用法,常用于时间补0
4.组件使用注意事项:
注册时如果使用驼峰命名,html代码中需要以-连接:
html中:
<my-com></my-com>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
components{
'myCom'
}
5.路由跳转方式:
//1:
<router-link to="/login"></router>
//2:编程时导航:
(1)this.
r
o
u
t
e
r
.
p
u
s
h
(
′
/
u
r
l
′
+
i
d
)
(
2
)
传
递
对
象
:
t
h
i
s
.
router.push('/url'+id) (2)传递对象: this.
router.push(′/url′+id)(2)传递对象:this.router.push({path:’/url’+id})
(3)传递命名的路由:
this.
r
o
u
t
e
r
.
p
u
s
h
(
n
a
m
e
:
′
g
o
o
d
s
I
n
f
o
′
,
p
a
r
a
m
s
:
i
d
)
/
/
3.
前
进
后
退
:
t
h
i
s
.
router.push({name:'goodsInfo',params:{id}}) //3.前进后退: this.
router.push(name:′goodsInfo′,params:id)//3.前进后退:this.router.go(n)//n为正负数值表示前进或后退多少
this.$router.back
6.路由切换高亮显示方式:
//1:直接添加.router-link-active{}类.
//2:vue实例中添加linkActiveClass:‘myActive’//自定义高亮类名
7.在手机上预览项目:
//1:cmd中运行ip config
//2:在package.json中的’dev’中指定’–host 局域网ip地址’
//3.移动设备中访问该局域网ip
***必须保证移动设备和项目运行在同一局域网