文档介绍:一、wxss
***@import语句可以导入外联样式表,***@import后跟需要导入的样式表的相对路径,用“;”表示语句结束。
(全局样式),在 page 的 wxss 文件中定义的样式为局部样式,只作用在对应的页面,并会覆盖 中相同的选择器。
***@import‘../../’ 却是不生效的。如果是引用文件和被引用文件在相同的目录下是生效的。即***@’的方式。
rpx(responsive pixel): 可以根据屏幕宽度进行自适应。规定屏幕宽为750rpx。
例: iPhone6 上,屏幕宽度为375px,共有750个物理像素,则750rpx = 375px = 750物理像素,1rpx = = 1物理像素。
‘.’开始的类选择器,可以使用标签选择器,控制同一类组件的样式。
二、wxml--标签语言
<!--wxml-->
<view>{ { message } }</view>
//
page({
data:{
message : ' hello! '
}
})
<view wx:for=" " ></view>
wx:for-item 可以指定数组当前元素的变量名
wx:for-index 可以指定数组当前下标的变量名
<view wx:if=" " ></view>
<view wx:elif=" " ></view>
<view wx:else=" " ></view>
<template name="msgItem">
<view>
<text>
{ { book} }
</text>
<text>
作者: { { author} }
</text>
<text>
出版时间: { { PublicatioDate} }
</text>
</view>
</template>
<template is="msgItem" data="...item" />
Page({ data: { item: { book: '少有人走的路',
author:'Scott Peck', synopsis: 'This book reveals the meaning munication and understanding everywhere. It transcends the age limit and helps us to explore the nature of love and lead us to a new, peaceful and rich life', PublicatioDate: '1987' } } })
三、js
给HTML添加data-*属性来传递我们需要的值
<view class="block" bindtap="playTap" data ></vie