uni-app icon indicating copy to clipboard operation
uni-app copied to clipboard

uni-app 编译到抖音mp-toutiao平台组件开启virtualHost后event不会触发

Open Moonofweisheng opened this issue 7 months ago • 3 comments

hbuilderX版本:4.22.2024062415-alpha 复现demo:toutiao-vue3-virtualhost
问题描述:
当组件开启了virtualHost后,运行到mp-toutiao平台,无法触发定义的test事件。 组件代码:

<template>
	<view class="test" @click="handleClick">点我测试</view>
</template>
<script lang="ts">
export default {
  name: 'virtual-host-cmp',
  options: {
    addGlobalClass: true,
    virtualHost: true,
    styleIsolation: 'shared'
  }
}
</script>
<script lang="ts" setup>
	const emit = defineEmits(['test'])
	function handleClick() {
		emit('test')
	}
</script>

使用:

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<virtual-host-cmp @test="handleTest"></virtual-host-cmp>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {

		},
		methods: {
				
			handleTest(){
				uni.showToast({
					title:'点到了'
				})
			}
		}
	}
</script>

Moonofweisheng avatar Jun 25 '24 08:06 Moonofweisheng