vue项目中,动态渲染数据时,截取(substring())字符串中的一段字符,出现错误(“TypeError: Cannot read property ‘substring’ of undefined”)
目的:截取 "2019-10-15T07:20:47.000Z"中的 2019-10-15,在文章中渲染
方法:利用字符串 substring()函数进行截取
- 函数:substring()
- 定义:substring(start,end)表示从start到end之间的字符串,包括start位置的字符但是不包括end位置的字符。
- 功能:字符串截取,比如想从"getUserDetails"中得到"getUser"就要用到substring(0,7)
如下:
<div class="time"