页面传值也不麻烦啊!利用组件的properties属性接收值。使用组件的页面js用onPageScroll,设置data中的显示标识如 showBotton,onPageScroll更新showBotton的显示与否状态。使用组件页面的wxml调用组件时,组件属性=showBotton,如<ToTopBtn showBtn="{{showBotton}}"></ToTopBtn>,组件内根据属性showBtn来判断显示与否<view class="goTop" hidden="{{!showBtn}}" bindtap="goTop">
自定义组件中如何使用onPageScroll?我打算封装个自定义的一键置顶组件(许多页面需要用到),但是onPageScroll好像在组件中用不了,现在是在用到的页面使用onPageScroll然后传值过去,但这样有点麻烦,有什么办法在组件中获取到scrollTop的值?
2022-10-10我也是新建组件后,就出现找不到组件wxml文件的错误。我的解决办法是:清空全部缓存>重新编译。这样就没错误出现了。
1.05.2204250 经常报Error -1152: WXML file not found错误: Error -1152: WXML file not found: 重现:修改布局后经常报错,重复点击编译后又正常了,这个应该是工具的bug 以下是错误: [ WXML 文件编译错误] 环境及执行信息: 编译器版本: 20220511 node版本: v16.4.2 参数: --config-path /tmp/4caf5c7bf045ba0ddfa67947953368d4 具体报错: Error -1152: WXML file not found: ././components/block-view/index>_<4207./components/cell/index>_<4207./components/cell-group/index>_<4207./components/checkbox/index>_<4207./components/checkbox-group/index>_<4207./components/col/index>_<4207./components/drag/index>_<4207./components/drawer/index>_<4207./components/image-selector/index>_<4207./components/image-view/index>_<4207./components/message/index>_<4207./components/refreshview/index>_<4207./components/row/index>_<4207./components/sheet/index>_<4207./components/sticky/index>_<4207./components/sticky-item/index>_<4207./components/swipeout/index>_<4207./components/switch/index>_<4207./components/tab-bar/index>_<4207./layer/login/index>_<4207./layer/modal/index>_<4207./layer/normal/index>_<4207./layer/paySuccess/index>_<4207./layer/register/index>_<4207./layer/userget/index>_<4207./pages/admin/appManage/index>_<4207./pages/admin/roomEdit/index>_<4207./pages/admin/roomManage/index>_<4207./pages/admin/roomManage/item/index>_<4207./pages/admin/roomOrderDetail/index>_<4207./pages/admin/roomOrderManage/index>_<4207./pages/admin/roomOrderManage/item/index>_<4207./pages/admin/roomOrderRevoke/index>_<4207./pages/admin/roomPrice/index>_<4207./pages/admin/roomStatusManage/index>_<4207./pages/admin/roomStatusManage/item/index>_<4207./pages/appraise/index>_<4207./pages/appraise/item/index>_<4207./pages/appraiseDetail/index>_<4207./pages/bookingDetail/index>_<4207./pages/bookingRoom/index>_<4207./pages/bookingRoom/item/index>_<4207./pages/home/index>_<4207./pages/index/index>_<4207./pages/me/index>_<4207./pages/roomDetail/index>_<4207./pages/roomOrder/index>_<4207./pages/roomOrder/orderItem/index>_<4207./pages/roomOrderDetail/index>_<4207./pages/userInfoEdit/index>_<4207./pagesComponents/appTextEdit/index>_<4207./pagesComponents/bookingDateSelector/index>_<4207./pagesComponents/dateSelector/index>_<4207./pagesComponents/hotelTags/index>_<4207./pagesComponents/huayuImage/index>_<4207./pagesComponents/price/index.wxml (env: Linux,mp,1.05.2204250; lib: 2.24.1) Uncaught FrameworkError Unexpected token '<' SyntaxError: Unexpected token '<'(env: Linux,mp,1.05.2204250; lib: 2.24.1)
2022-09-23demo.js是修改样式模板的文件,在根目录下自己新建,主要代码如下: const wxml = ` <view class="container"> <image class="img" src="/image/sharebg.jpg"></image> </view> </view> ` const style = { container: { width: 300, height: 200, flexDirection: 'row', justifyContent: 'space-around', backgroundColor: '#ccc', alignItems: 'center', }, itemBox: { width: 80, height: 60, }, text: { width: 80, height: 60, textAlign: 'center', verticalAlign: 'middle', }, img: { width: '100', height: '100', } } module.exports = { wxml, style }
这句话什么意思?在哪引入的wxml,style。我这没有demo.js这个文件。能不能说清楚啥意思const {wxml, style} = require('./demo.js')
2021-07-26