小程序

关于模板,参见:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/view/wxml/template.html

 

引入模块

<import src="news-template/news-template.wxml" />

注意,一定要有结束符,不然一定会报错

 

 

新建模板以后

 

 为何不再使用item? 因为item被省略了!

 

 

 

inews.wxss导入template.wxss

关于wxss导入请参见:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/view/wxss.html

 

 

请注意,wxss和wxml导入方式是不一样的!

为何将代码分离? 高耦合,低内聚

点击获取源码:https://gitee.com/null_717_7167/Wechat-code/repository/archive/master.zip

原文地址:https://www.cnblogs.com/cisum/p/8601621.html