Skip to content

uni-app使用支付宝官方扩展组件提示事件信息不存在 #917

Closed
@chen-can

Description

@chen-can

引入官方card组件,执行点击事件
image
这个问题前3个月已经提出了 怎么还没有回复 是不支持小程序自定义组件mycomponents 吗
如果是请修改文档 以免后续开发者不断踩坑

Activity

chen-can

chen-can commented on Oct 28, 2019

@chen-can
Author

#790 还有这个问题 至今没有给出回复

andyWHJ

andyWHJ commented on Feb 28, 2020

@andyWHJ

麻烦官方给个回复,谢谢

mehaotian

mehaotian commented on Jul 3, 2020

@mehaotian
Contributor

目前先这样绕过解决一下,在 onLoad 添加如下代码 this.$scope.cardClick = this.cardClick.bind(this)

其他组件的其他方法类似 ,先手动把事件绑定到 this.$scope 上面

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view>
			<text class="title">{{title}}</text>
		</view>
     <card
       :thumb="title"
       title="卡片标题2"
       subTitle="副标题非必填2"
       onClick="cardClick"
       info="点击了第二个card"
     />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			this.$scope.cardClick = this.cardClick.bind(this)
		},
		methods: {
			cardClick(){
				console.log('卡片被点击了');
			}
		}
	}
</script>
tyust512

tyust512 commented on May 19, 2022

@tyust512

请问你是在页面的onLoad生命周期加了这代码,就解决了?能说下原理吗

3crazyspecial

3crazyspecial commented on Oct 20, 2022

@3crazyspecial

请问这个问题还是只能绕过吗?

目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

zhetengbiji

zhetengbiji commented on Oct 21, 2022

@zhetengbiji
Collaborator

请问这个问题还是只能绕过吗?

目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

很久以前已经修复

3crazyspecial

3crazyspecial commented on Oct 21, 2022

@3crazyspecial

请问这个问题还是只能绕过吗?
目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

很久以前已经修复

我目前发现还是不行,主要是 Vue 的 store,目前发现编译后的代码执行回调函数是 publicInstance 中我的 method 是 undefinded

image

目前不知道是啥原因,这个修复的版本是多少呢?

zhetengbiji

zhetengbiji commented on Oct 21, 2022

@zhetengbiji
Collaborator

请问这个问题还是只能绕过吗?
目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

很久以前已经修复

我目前发现还是不行,主要是 Vue 的 store,目前发现编译后的代码执行回调函数是 publicInstance 中我的 method 是 undefinded

image

目前不知道是啥原因,这个修复的版本是多少呢?

建议使用最新的alpha版测试一下,另外你的代码写法看一下,是不是监听事件的方式错了

3crazyspecial

3crazyspecial commented on Oct 21, 2022

@3crazyspecial

请问这个问题还是只能绕过吗?
目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

很久以前已经修复

我目前发现还是不行,主要是 Vue 的 store,目前发现编译后的代码执行回调函数是 publicInstance 中我的 method 是 undefinded
image
目前不知道是啥原因,这个修复的版本是多少呢?

建议使用最新的alpha版测试一下,另外你的代码写法看一下,是不是监听事件的方式错了

代码监听方式没有问题的,用的一个空项目,目前发现精简代码后发现,不使用 Router 就没问题

zhetengbiji

zhetengbiji commented on Oct 21, 2022

@zhetengbiji
Collaborator

请问这个问题还是只能绕过吗?
目前这个方式在不使用 store 的场景下是可行的,不过有 store 后函数就不对了

很久以前已经修复

我目前发现还是不行,主要是 Vue 的 store,目前发现编译后的代码执行回调函数是 publicInstance 中我的 method 是 undefinded
image
目前不知道是啥原因,这个修复的版本是多少呢?

建议使用最新的alpha版测试一下,另外你的代码写法看一下,是不是监听事件的方式错了

代码监听方式没有问题的,用的一个空项目,目前发现精简代码后发现,不使用 Router 就没问题

使用的 uni-app 版本多少?
怎么监听的事件?

3crazyspecial

3crazyspecial commented on Oct 21, 2022

@3crazyspecial

编辑器版本 3.6.4.20220922,下图中 mycom 是支付宝原生组件,组件内部正常执行,但是回调函数没有执行,根据上面的判断是没有找到相关函数,目前做依赖判断的时候发现添加 uni-simple-router 后开始不符合预期

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<mycom onLoad="onLoad" ></mycom>
	</view>
</template>

<script>
	let pluginIns;
	export default {
		data() {
			return {
			}
		},
		onLoad() {
			this.$scope.onLoad = this.onLoad.bind(this)
		},
		methods: {
			onLoad: () => {
                                 console.log('onLoad')
			}
		}
	}
</script>
zhetengbiji

zhetengbiji commented on Oct 21, 2022

@zhetengbiji
Collaborator

编辑器版本 3.6.4.20220922,下图中 mycom 是支付宝原生组件,组件内部正常执行,但是回调函数没有执行,根据上面的判断是没有找到相关函数,目前做依赖判断的时候发现添加 uni-simple-router 后开始不符合预期

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<mycom onLoad="onLoad" ></mycom>
	</view>
</template>

<script>
	let pluginIns;
	export default {
		data() {
			return {
			}
		},
		onLoad() {
			this.$scope.onLoad = this.onLoad.bind(this)
		},
		methods: {
			onLoad: () => {
                                 console.log('onLoad')
			}
		}
	}
</script>
  1. 你这事件写法是错误的,应该用 v-on(@) 的方式监听事件
  2. 不建议用和生命周期同名的方法
  3. 建议升级到 3.6.7

修改后如下:

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<mycom @load="onMyLoad" ></mycom>
	</view>
</template>

<script>
	let pluginIns;
	export default {
		data() {
			return {
			}
		},
		methods: {
			onMyLoad: () => {
                                 console.log('onLoad')
			}
		}
	}
</script>

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @zhetengbiji@andyWHJ@tyust512@3crazyspecial@mehaotian

      Issue actions

        uni-app使用支付宝官方扩展组件提示事件信息不存在 · Issue #917 · dcloudio/uni-app