提交 1d6a604d 编写于 作者: H hdx

feat($parent): 放开入口,新增测试例子

上级 b9f1c40b
<template> <template>
<view class="page"> <view class="page">
<child></child> <form>
<child ref="child"></child>
</form>
<view>
<button @click="testParent" class="call-parent-func">调用组件所在页面方法</button>
</view>
<view>
<text>{{parentValue}}</text>
</view>
</view> </view>
</template> </template>
<script> <script>
import child from './child.uvue' import child from './child.uvue'
export default { export default {
components: { components: {
child child
}, },
data () { data() {
return { return {
value: "parent" value: "parent",
} parentValue: "123"
}, }
methods: { },
testFunction (): string { methods: {
return "parentFunctionResult" testFunction() : string {
return "parentFunctionResult"
},
testParent() {
const child = this.$refs['child'] as ComponentPublicInstance
this.parentValue = child.$parent!.$callMethod('testFunction') as string
},
} }
} }
}
</script> </script>
<style> <style>
.page { .page {
display: flex; display: flex;
flex-direction: row;
justify-content: space-between; justify-content: space-between;
} }
</style> </style>
\ No newline at end of file
...@@ -306,12 +306,7 @@ ...@@ -306,12 +306,7 @@
{ {
name: '$parent', name: '$parent',
url: 'parent', url: 'parent',
// #ifdef APP
enable: true, enable: true,
// #endif
// #ifdef WEB
enable: false,
// #endif
}, },
{ {
name: '$root', name: '$root',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册