1***@qq.com
1***@qq.com
  • 发布:2019-05-15 14:36
  • 更新:2019-07-09 16:02
  • 阅读:1893

uniapp在编译到小程序后一些vue特性不支持?

分类:uni-app

在模版中函数绑定的方式在web上没问题 转换到小程序中就有问题。

比如list里面还有个array
data大概是这样的
list:[
user:{
tags:[....],
name:'jack'
}
],

然后我开始for循环渲染出来,有时候我想处理一下每个tag的文案

<view class="item" v-for="item in list">
<text>userName<text>
<text v-for="tag in formatTags(item.user.tags)">{{tag}}<text>
</view>

method:{
formatTags(tags){
return tags.map(....)
}
}

这样就有问题,web平台没问题,但是编译到小程序就有问题formatTags出不来数据

即便不是array这样的类型

连普通的文本 在属性层级很深的时候也有问题,比如

<view class="item" v-for="item in list">
<text>{{formatName(item.user.name)}}<text>
</view>

method:{
formatName(name){
return 'firstName:' name
}
}
会提示item为undefine

附件里是写的demo,web上没问题 vue的很多特性都有,但是转换的小程序里很多特性语法都有问题。
目前我的解决方式是在setData前先format好要显示的数据,但是很多情况需要动态显示的就很麻烦。
是我使用方式的问题?或者这样有什么多平台都能正常运行的方式吗?

2019-05-15 14:36 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者) - o

我新测试了一下
<view class="item" v-for="item in list">
<text>userName<text>
<text v-for="tag in formatTags(item.user.tags)">{{tag}}<text>
</view>

这段没问题

但是类似在模版for循环里
<text>{{formatName(item.user.name)}}<text>
这样用多层属性套方法有问题

8***@qq.com

8***@qq.com

同样遇到相似的问题。
我想用个格式化日期的方法格式{{}}中的值结果为空
<view style="text-align: left;">{{formatDate(item.question_info.update_time) }}{{test()}}</view>
methods:{
formatDate:function(timestap){
let time = new Date(timestap)
return time
},
}

DCloud_UNI_FXY

DCloud_UNI_FXY

更新最新 HBuilderX,启用自定义组件模式,https://ask.dcloud.net.cn/article/35843

该问题目前已经被锁定, 无法添加新回复