详细问题描述: 组件内js方法调用不成功,只存在于百度小程序,H5微信小程序无问题,(如果不用组件直接在原页面写则生效)
[内容]
重现步骤
[步骤]
组件内写法是这样的:
<template>
<view class="header">
<navigator url="#" class="backlast">
<button type="default"></button>
</navigator>
<navigator url="https://m.lmjx.net"
class="backhome">
<button type="default"></button>
</navigator>
<text class="htitle">挖掘机</text>
<button class="nav-trigger" @click="showNav"><i></i><i></i><i></i></button>
<button class="hsearch"></button>
<!-- 导航 -->
<view class="hnav psta" v-if="navShow">
<navigator url="https://m.lmjx.net" hover-class="none" class="hnav-item">
<button type="default">首页</button>
</navigator>
<navigator url="#" hover-class="none" class="hnav-item">
<button type="default">买设备</button>
</navigator>
<navigator url="#" hover-class="none" class="hnav-item">
<button type="default">看新闻</button>
</navigator>
<navigator url="#" hover-class="none" class="hnav-item">
<button type="default">搜索</button>
</navigator>
<navigator url="#" hover-class="none" class="hnav-item">
<button type="default">高清图</button>
</navigator>
</view>
</view>
</template>
<script>
export default {
data() {
return {
navShow: false
}
},
methods: {
showNav: function(){
console.log('click', 11111)
}
},
created() {
console.log('header', this.navShow)
}
}
</script>
<style>
.header {
position: fixed;
height: 88upx;
background-color: #198ef6;
width: 100%;
z-index: 7;
top: 0;
}
.backlast,
.backhome {
display: block;
float: left;
width: 88upx;
height: 88upx;
background: url(https://u-static.lmjx.net/2019/m/images/backbtn.png) center center no-repeat;
background-size: 20upx 36upx;
}
.backhome {
background: url(https://u-static.lmjx.net/2019/m/images/home.png) center center no-repeat;
background-size: 36upx 36upx;
}
.header .nav-trigger {
display: block;
float: right;
width: 82upx;
height: 88upx;
padding: 22upx 0;
overflow: hidden;
background: none;
border-radius: 0;
box-sizing: border-box;
}
.header .nav-trigger i {
display: block;
width: 36upx;
height: 4upx;
margin: 8upx auto 0;
-webkit-border-radius: 2upx;
border-radius: 2upx;
overflow: hidden;
background-color: #fff;
}
.htitle {
display: block;
float: left;
width: 400upx;
height: 88upx;
padding: 16upx 2upx 0;
font-size: 28upx;
line-height: 56upx;
text-align: center;
color: #fff;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.hsearch {
position: relative;
float: right;
width: 88upx;
height: 88upx;
border-radius: 4upx;
background: url(https://u-static.lmjx.net/2019/m/images/search.png) center center no-repeat;
background-size: 32upx 30upx;
font-size: 24upx;
line-height: 56upx;
color: #fff;
}
/ 导航 /
.hnav {
width: 220upx;
z-index: 6;
opacity: 1;
right: 0;
top: 88upx;
border-bottom: 2upx solid #bfbfbf;
box-sizing: border-box;
background: #fff;
}
.hnav-item button {
display: block;
background-color: #fff;
font-size: 30upx;
line-height: 65upx;
text-align: center;
color: #333;
border: 2upx solid #bfbfbf;
border-bottom: 0;
border-radius: 0;
}
</style>
[结果]
百度小程序下 周期函数created无执行,click事件无执行;
[期望]
可以正常执行
IDE运行环境说明
[HBuilderX版本号] 1.9.1.20190415
[windows版本号] windows 7
联系方式
[QQ] 3518356160
运行截图如下: