组件是试图容层的基本组成单元,自带一些基本功能以及微信风格的样式。
其实,微信小程序的组件就是开发框架对HTML5元素的封装。通过使用组件就可以引用HTML5的相关元素了。
如:view组件,与HTML中的div类似。
pags/index/index.wxml文件内容
< !--index.wxml-->< view class="container">
< view bindtap="bindViewTap" class="userinfo">
< image class="userinfo-avatar" src="{
{userInfo.avatarUrl}}" background-size="cover">< /image>
< text class="userinfo-nickname">{
{userInfo.nickName}}< /text>
< /view> < view class="usermotto">
< text class="user-motto">{
{motto}}< /text>
< /view>
< /view>
运行结果如图
view全不替换为div结果仍是如此。
但要注意&#x