举例:封装一个“搜索框”组件
1、首先新建一个组件,用来存放公用的SearchInput
具体新建过程:目录根部右击创建文件夹components,再右击components =>新建文件夹 ,然后定义名字为SearchInput,右击SearchInput =>创建组件Component,SearchInput组件便创建成功
2、组件创建好后,开始编写具体实现功能代码
components/SearchInput/SearchInput.wxml:
<!--components/SearchInput/SearchInput.wxml-->
<view class="search">
<view class="search-input">
<view class="search-content">
<image src="/icon/search.png"></image>
<text>搜索</text>
</view>
</view>
</view>
c