1***@qq.com
1***@qq.com
  • 发布:2018-12-01 15:41
  • 更新:2020-08-07 14:59
  • 阅读:9244

uni-app使用小程序自定义组件,小程序组件如何调用父组件uni-app的函数?

分类:uni-app

uni-app使用小程序自定义组件,小程序组件如何调用父组件uni-app的函数?,在小程序中是
this.triggerEvent('lowValueChange', myEventDetail) 这样的,但是把小程序组件放在根目录,子组件没办法触发uni-app页面中的组件函数????

2018-12-01 15:41 1 条评论 负责人:无 分享
已邀请:
悠闲的程序员

悠闲的程序员

使用 this.$emit()

  • itdage

    不对

    index.umd.min.js:1 [system] errorHandler TypeError: Cannot read property 'toLowerCase' of undefined

    at VueComponent.Vue.$emit (vue.runtime.esm.js:3865)

    at VueComponent.click (index2.vue:34)

    at click (index2.vue?a5a8:64)

    at invokeWithErrorHandling (vue.runtime.esm.js:1854)

    at VueComponent.invoker (vue.runtime.esm.js:2179)

    at invokeWithErrorHandling (vue.runtime.esm.js:1854)

    at VueComponent.Vue.$emit (vue.runtime.esm.js:3882)

    at VueComponent.onClick (uni-grid.vue:68)

    at click (uni-grid.vue?84ce:37)

    at invokeWithErrorHandling (vue.runtime.esm.js:1854)

    2019-04-23 14:17

  • i***@qq.com

    头条小程序不支持this.$emit()??


    index.js:2 Uncaught SyntaxError: Unexpected token {

    at eval (<anonymous>)

    at window.loadScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277)

    at te (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:10142)

    at Q (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:9502)

    at eval (list-service.js:1)

    at eval (<anonymous>)

    at window.loadScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277)

    at fo (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:54517)

    at vo (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:55358)

    at So (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:56663)

    at Function.eval (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:293593)

    at eval (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:24507)

    at eval (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:278528)

    at Array.forEach (<anonymous>)

    at Function.eval (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:278508)

    at eval (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:262041)

    at Object.O (eval at window.loadTmaScript (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277), <anonymous>:1:4269)

    at C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277

    at EventEmitter.<anonymous> (C:\Users\wenjie\AppData\Local\Programs\bytedanceide\resources\app.asar.unpacked\simulator-sdk\dist\preload\bgPreload.9cf8b4ceae02ff97f08b.js:277)

    at EventEmitter.emit (events.js:182)

    2020-03-20 10:32

j***@126.com

j***@126.com

请问这个问题有什么解决方案吗?

程咬金3斧头

程咬金3斧头

一楼说的$emit就是正解。

L***@163.com

L***@163.com

将支付宝小程序组件放在uniapp项目的mycomponents文件夹下运行报错Can not find Component /mycomponents/map/index in Page: pages/user/trip/trip-detail。是怎么回事呢。小程序里配置了"component": true,还是不行

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