Closed
Description
问题描述
使用插槽内容访问子组件中才有的数据时,导致插槽内容无法访问父组件数据
复现步骤
组件A
<template>
<view><slot name="title" show="test"></slot></view>
</template>
父组件
<template>
<view>
{{title}}
<A>
<view v-slot:title="{show}">
{{title}}
</view>
</A>
</view>
</template>
<script>
export default {
data () {
return {
title: 'test'
}
}
}
</script>
预期结果
可以看到A组件外面的tiltle渲染成了test,A里面的title渲染成了test
实际结果
A组件外面的tiltle渲染成了test,A里面的title渲染成了undefined
系统信息:
- 发行平台: 微信小程序
- 操作系统 Android 7.0
- HBuilderX版本 [如使用HBuilderX,则需提供 HBuilderX 版本号]
- uni-app版本 [如使用Vue-cli创建/运行项目,则提供
npm run info
的运行结果]
System:
OS: Windows 10
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Binaries:
Node: 11.6.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
npmPackages:
@dcloudio/uni-app-plus: ^0.0.247 => 0.0.247
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-cli-shared: ^0.2.963 => 0.2.963
@dcloudio/uni-h5: ^0.5.12 => 0.5.12
@dcloudio/uni-mp-alipay: ^0.0.821 => 0.0.821
@dcloudio/uni-mp-baidu: ^0.0.849 => 0.0.849
@dcloudio/uni-mp-toutiao: ^0.0.345 => 0.0.345
@dcloudio/uni-mp-weixin: ^0.0.966 => 0.0.966
@dcloudio/uni-template-compiler: ^0.9.179 => 0.9.179
@dcloudio/vue-cli-plugin-hbuilderx: ^1.0.100 => 1.0.100
@dcloudio/vue-cli-plugin-uni: ^0.9.482 => 0.9.482
@dcloudio/webpack-uni-mp-loader: ^0.3.630 => 0.3.630
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: ^0.2.846 => 0.2.846
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: 3.8.0
@vue/babel-preset-jsx: 1.0.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.0.0
@vue/cli-overlay: 3.8.0
@vue/cli-plugin-babel: ^3.8.0 => 3.8.0
@vue/cli-service: ^3.8.4 => 3.8.4
@vue/cli-shared-utils: 3.8.0
@vue/component-compiler-utils: 2.6.0
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^5.2.2 => 5.2.2
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^2.6.10 => 2.6.10
vue-eslint-parser: 5.0.0
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.0
vue-router: 3.0.1
vue-style-loader: 3.1.2 (3.1.2)
vue-template-compiler: ^2.6.10 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vuex: ^3.1.1 => 3.1.1
weex-vue-loader: ^0.7.0 => 0.7.0
- 设备信息 [如 iPhone8 Plus]
补充信息
[可选]
[根据你的分析,出现这个问题的原因可能在哪里?]