js目录在 static/data/city.js
页面的test.wx在目录 pages/test.wx
在test.wx中引入js:
import city from '../static/data/city.js'
举例:如果要使用flyos.js替换wx.request,需要在在使用async/await时每个.wx文件中写入import regeneratorRuntime from 'regenerator-runtime'
也可以挂在全局变量,参见框架工程的static/utils/system.js的做法,不过并不推荐。
less目录在 static/styles/test.less
wxss目录在 static/styles/test.wxss
页面的test.wx在目录 pages/test.wx
在test.wx中引入less:
@import '../static/styles/test.less';
在test.wx中引入wxss:
@import '../static/styles/test.wxss';
import
可以在该文件中使用目标文件定义的template
,如:
在 item.wxml 中定义了一个叫item
的template
:
<!-- item.wxml -->
<template name="item">
<text>{{text}}</text>
</template>
在 index.wx 中引用了 item.wxml,就可以使用item
模板:
<import src="item.wxml"/>
<template is="item" data="{{text: 'forbar'}}"/>
注意:模版不支持引入wx文件,只支持引入wxml。此外,模板名字如果带-
可能导致引入出错。