看代码:
Vue提供了强大的前端开发架构,很多时候我们需要判断数据对象是否为空,使用typeof判断是个不错选择,具体代码见图。
补充知识:vue打包后 history模式 跟子目录 静态文件路径 分析
history
根目录
路由mode变为history后,需要在服务器配置 url重写,在根目录 创建web.config文件 加下面内容复制进去
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<? xml version = "1.0" encoding = "utf-8" ?> < configuration > < system.webServer > < rewrite > < rules > < rule name = "Handle History Mode and custom 404/500" stopProcessing = "true" > < match url = "(.*)" /> < conditions logicalGrouping = "MatchAll" > < add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "true" /> < add input = "{REQUEST_FILENAME}" matchType = "IsDirectory" negate = "true" /> </ conditions > < action type = "Rewrite" url = "/index.html" /> </ rule > </ rules > </ rewrite > </ system.webServer > </ configuration > |
background: url('/static/logo.png') no-repeat center/ 50%; 跟路径 / 和 相对路径
<img src="/static/logo.png" js" id="highlighter_800544">
123456<img :src=
"image"
alt=
""
srcset=
""
> 跟路径 / 和../
data () {
return
{
image:
'../static/logo.png'
}
}