美文网首页
CnodeJS-Vue 遇到的问题

CnodeJS-Vue 遇到的问题

作者: YZY君 | 来源:发表于2017-08-04 10:58 被阅读41次

<span>{{index+1}}楼•{{reply.create_at.substr(0,10)}}</span>
另一个组件中同样使用的{{item.create_at.substr(0,10)}}没有问题,这里会报错,但是页面内容显示正常。

vue.esm.js?65d7:479 [Vue warn]: Error in render function: "TypeError: Cannot read property 'substr' of undefined"

found in

---> <ArticleComp> at /Users/yzy/CODE/CnodeJS-Vue/src/components/articleComp.vue
       <App> at /Users/yzy/CODE/CnodeJS-Vue/src/App.vue
         <Root>
vue.esm.js?65d7:566 TypeError: Cannot read property 'substr' of undefined
    at Proxy.render (articleComp.vue?9c74:25)
    at VueComponent.Vue._render (vue.esm.js?65d7:4128)
    at VueComponent.updateComponent (vue.esm.js?65d7:2538)
    at Watcher.get (vue.esm.js?65d7:2881)
    at new Watcher (vue.esm.js?65d7:2870)
    at mountComponent (vue.esm.js?65d7:2542)
    at VueComponent.Vue$3.$mount (vue.esm.js?65d7:7863)
    at VueComponent.Vue$3.$mount (vue.esm.js?65d7:10066)
    at init (vue.esm.js?65d7:3501)
    at createComponent (vue.esm.js?65d7:5147)

v-for 的index 使用

v-for遍历数组时的参数顺序 变更

当包含 index时,之前遍历数组时的参数顺序是 (index, value)。现在是 (value, index),来和 JavaScript 的原生数组方法(例如 forEach和 map)保持一致。

 <div class="cell" v-for='(reply,index) in article.replies'>
   <span>{{index+1}}楼•{{reply.create_at.substr(0,10)}}</span>
</div>

相关文章

  • CnodeJS-Vue 遇到的问题

    {{index+1}}楼•{{reply.create_at.substr(0,10)}} 另一个组件中同样使用的...

  • CnodeJS-Vue(一)

    创建项目 vue init webpack CnodeJS-Vue 一开始用了 vue init webpack-...

  • 遇到的问题

    express 搭建脚手架 - 因为chroma网络设置开了代理导致无法显示页面。。。。。。。。 express...

  • 遇到的问题

    还需要学习的东西vue源码nodejshttp等网络知识typescript设计模式 还需要刷的题牛客网前端50题...

  • 遇到的问题

    Dom4J 使用Dom4J解析XML文件时,遇到&时,程序异常信息“Error on line 1 of docu...

  • 遇到的问题

    【报错】变量 is not callable 当出现报错 XXX is not callable的时候,很有可能是...

  • AS遇到的问题

    Q 一些jar包提示Failed to resolve: com.squareup.retrofit:retrof...

  • 遇到的问题

    1.列表页右侧进度条没有,原因是:设置了body的overflow:hidden,范围设置太广,导致整个页面的ov...

  • 遇到的问题

    appcode 不能真机运行 Error:Safe Area Layout Guide before iOS 9....

  • 遇到的问题

    自主学习在线上课 在线上课又分成了各种细类别,中教1v1,外交1v1,小班课4,小班课8,在枚举里面,慢慢淘汰旧的...

网友评论

      本文标题:CnodeJS-Vue 遇到的问题

      本文链接:https://www.haomeiwen.com/subject/gbrvlxtx.html