umicro / uView

uView UI,是uni-app生态最优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
MIT License
4.08k stars 769 forks source link

dropdown组件在微信小程序中的问题 #493

Open iNuoers opened 4 years ago

iNuoers commented 4 years ago

版本号:1.7.0 使用方式: `

在h5中正常,但是在微信小程序中报如下错误: VM21:1 [Vue warn]: Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> at node_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue

at node_modules/uview-ui/components/u-dropdown/u-dropdown.vue pages/index/index.vue console.error @ VM21:1 warn @ vendor.js:5071 warnNonPresent @ vendor.js:6473 get @ vendor.js:6528 render @ u-dropdown-item.js:96 Vue._render @ vendor.js:8008 updateComponent @ vendor.js:10144 get @ vendor.js:8868 Watcher @ vendor.js:8857 mountComponent$1 @ vendor.js:10150 Vue.$mount @ vendor.js:10473 attached @ vendor.js:1501 r.safeCallback @ VM28 WAService.js:2 r.call @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 m @ VM28 WAService.js:2 y.pretendAttached @ VM28 WAService.js:2 Nt @ VM28 WAService.js:2 jt @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 Mt @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i.emit @ VM28 WAService.js:2 emit @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i.emit @ VM28 WAService.js:2 emit @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i @ VM26 asdebug.js:1 c @ VM26 asdebug.js:1 (anonymous) @ VM26 asdebug.js:1 p @ VM26 asdebug.js:1 f @ VM26 asdebug.js:1 (anonymous) @ VM26 asdebug.js:1 _ws.onmessage @ VM26 asdebug.js:1 Show 12 more frames VM21:1 [Vue warn]: Error in render: "TypeError: Cannot read property 'value' of undefined" found in ---> at node_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue at node_modules/uview-ui/components/u-dropdown/u-dropdown.vue pages/index/index.vue console.error @ VM21:1 warn @ vendor.js:5071 Vue.config.errorHandler @ vendor.js:10260 globalHandleError @ vendor.js:6332 handleError @ vendor.js:6301 Vue._render @ vendor.js:8010 updateComponent @ vendor.js:10144 get @ vendor.js:8868 Watcher @ vendor.js:8857 mountComponent$1 @ vendor.js:10150 Vue.$mount @ vendor.js:10473 attached @ vendor.js:1501 r.safeCallback @ VM28 WAService.js:2 r.call @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 r @ VM28 WAService.js:2 m @ VM28 WAService.js:2 y.pretendAttached @ VM28 WAService.js:2 Nt @ VM28 WAService.js:2 jt @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 Mt @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i.emit @ VM28 WAService.js:2 emit @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i.emit @ VM28 WAService.js:2 emit @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 (anonymous) @ VM28 WAService.js:2 i @ VM26 asdebug.js:1 c @ VM26 asdebug.js:1 (anonymous) @ VM26 asdebug.js:1 p @ VM26 asdebug.js:1 f @ VM26 asdebug.js:1 (anonymous) @ VM26 asdebug.js:1 _ws.onmessage @ VM26 asdebug.js:1 Show 12 more frames VM21:1 TypeError: Cannot read property 'value' of undefined at Proxy.render (u-dropdown-item.js:96) at VueComponent.Vue._render (vendor.js:8008) at VueComponent.updateComponent (vendor.js:10144) at Watcher.get (vendor.js:8868) at new Watcher (vendor.js:8857) at mountComponent$1 (vendor.js:10150) at VueComponent.Vue.$mount (vendor.js:10473) at Xe.attached (vendor.js:1501) at r.safeCallback (VM28 WAService.js:2) at r.call (VM28 WAService.js:2)`
iNuoers commented 4 years ago

错误消息

tttao7 commented 4 years ago

建议把js部分也贴一下

iNuoers commented 4 years ago

建议把js部分也贴一下

没有js,就是官方的demo,直接贴到我自己的项目中。h5可以运行,小程序中就报错了,但是页面上也可以正常显示。

Sea-f commented 4 years ago

解决了吗

yanwenjia commented 4 years ago

遇到了同样的问题

yung-Twist commented 4 years ago

+1

dong-king commented 3 years ago

版本号:1.8.3 示例工程未作任何修改,使用hbuilderx编译成微信小程序,也有该问题出现。 经定位,是因为u-dropdown-item.vue文件中的行内title-style样式中引入了item。 `<u-cell-item :arrow="false" :title="item.label" v-for="(item, index) in options" :key="index" :title-style="{ color: value == item.value ? activeColor : inactiveColor }" @click="cellClick(item.value)">

                    </u-cell-item>`

我的做法是将title-style改写成: :title-style="value == item.value ? activeColorObj : inactiveColorObj" 然后再定义两个computed属性: activeColorObj() { return { color: this.activeColor } }, inactiveColorObj() { return { color: this.inactiveColor } }