建立文件夹showTip位于component下面:
对应Component四个文件搞好:
json:
{
"component": true,
"usingComponents": {}
}
js:
Component({
properties
: {
is_show
:{
type
:Boolean
,
value
:false
},
title
: {
type
: String
,
value
: '标题'
},
content
: {
type
: String
,
value
: '内容'
},
btn
: {
type
: String
,
value
: '知道了'
},
},
data
: {
},
methods
: {
exitShowtip(){
this.setData({
is_show
:!this.data
.is_show
,
})
}
},
})
wxss:
.showtip-box{
width: 400rpx
;
height: 500rpx
;
background: #F5F5F5
;
border-radius: 30rpx
;
position: absolute
;
left: 50%
;
top: 50%
;
transform: translate(-50%,-50%
);
padding: 0 30rpx
;
}
.showtip-box .title{
font-size: 32rpx
;
text-align: center
;
line-height: 80rpx
;
}
.showtip-box .btn{
background: #0000FF
;
color: #fff
;
line-height: 70rpx
;
border-radius: 12rpx
;
text-align: center
;
font-size: 26rpx
;
margin: 30rpx 0 0 0
;
}
.showtip-box .show-content{
height: 300rpx
;
font-size: 26rpx
;
color: #333
;
text-align: center
;
}
wxml:
<!--component
/showTip
/showtip
.wxml
-->
<view
class="showtip-box" wx
:if="{{ is_show }}">
<view
class="title">{{ title
}}</view
>
<view
class="show-content">
{{ content
}}
</view
>
<view
class="btn" bindtap
="exitShowtip">{{ btn
}}</view
>
</view
>
调用:在pages里随便建立一个,用于演示
谁调用谁json文件要引入
我建立index,那么index.json要引入
{
"usingComponents": {
"showtip": "/component/showTip/showtip"
}
}
要调用wxml:
<showtip is_show
='true' title
='标题' content
='我是内容'></showtip
>
转载请注明原文地址: https://mac.8miu.com/read-483868.html