We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题描述
页面继承基类,子类编译后的 wxml 文件会自动 import 基类的 wxml文件,不影响程序运行但是开发者工具会报警告
复现步骤
base.ts
import Taro from '@tarojs/taro' export default class Base<Props, State> extends Taro.Component<Props, State> { onReachBottom () { Taro.eventCenter.trigger('onScrollToLower') } }
home.tsx
import Taro from '@tarojs/taro' import { View } from '@tarojs/components' import Base from './base' import './index.scss' type State = {} type Props = {} export default class Home extends Base<Props, State> { render () { return ( <View className='home'> { this.renderTest() } </View> ) } renderTest () { return ( <View>test</View> ) } }
编译后的 home.wxml 文件
<import src="./base.wxml" /> <block wx:if="{{$taroCompReady}}"> <view class="home"> <template is="renderTest" data="{{...anonymousState__temp}}"></template> </view> </block> <template name="renderTest"> <block> <view>test</view> </block> </template>
期望行为
编译后不引用不存在的 base.wxml 文件
<import src="./base.wxml" />
报错信息
WXMLRT_$gwx:./pages/home/home.wxml:import:1:1: Path `./base.wxml` not found from `./pages/home/home.wxml`. ./pages/home/home.wxml Path `./base.wxml` not found from `./pages/home/home.wxml`. > 1 | <import src="./base.wxml" /> | ^ 2 | <block wx:if="{{$taroCompReady}}"> 3 | <view class="home"> 4 | <template is="renderTest" data="{{...anonymousState__temp}}"></template>
系统信息
补充信息
home.tsx 中的 render 如果不调用 renderTest() 那么编译后的 home.wxml 就不会引用 base.wxml 文件了
import Taro from '@tarojs/taro' import { View } from '@tarojs/components' import Base from './base' import './index.scss' type State = {} type Props = {} export default class Home extends Base<Props, State> { render () { return ( <View className='home'> <View>test</View> </View> ) } }
编译后的 home.wxml
<block wx:if="{{$taroCompReady}}"> <view class="home"> <view>test</view> </view> </block>
The text was updated successfully, but these errors were encountered:
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
Sorry, something went wrong.
CC @yuche
你把组件 Home 的 render() 放在最后面就不会有这个报错了,因为编译器解析是自上而下的,解析到 render 方法的时候并不知道它的自己有 renderTest 方法,所以就打算从父类去寻找。
Home
render()
98c2f86
fix(eslint): 组件方法按最佳实践推荐的顺序书写,close #3914
66000eb
yuche
No branches or pull requests
问题描述
页面继承基类,子类编译后的 wxml 文件会自动 import 基类的 wxml文件,不影响程序运行但是开发者工具会报警告
复现步骤
base.ts
home.tsx
编译后的 home.wxml 文件
期望行为
编译后不引用不存在的 base.wxml 文件
报错信息
系统信息
补充信息
home.tsx 中的 render 如果不调用 renderTest() 那么编译后的 home.wxml 就不会引用 base.wxml 文件了
home.tsx
编译后的 home.wxml
The text was updated successfully, but these errors were encountered: