微信小程序如何引用外部微信小程序如何引用外部js,外部样式,公共页面模板,外部样式,公共页面模板
小程序引用外部小程序引用外部js
//封装的函数
function GetUserInfo2018() {
console.log("获取用户信息8888")
}
function count(str) {
console.log(str)
}
//转化成小程序模板语言 这一步非常重要 不然无法正确调用
module.exports = {
GetUserInfo2018: GetUserInfo2018,
count: count
};
/*其它页面调用
var common = require("../common/common.js");
common.GetUserInfo2018();
common.count("hehe");
*/
小程序引用外部小程序引用外部css
/*
app.wxss是全局样式,作用于每一个页面,
而page下的每一个的wxss文件只作用于当前页面,并对全局样式中的相同属性会覆盖
*/
@import "../../app.wxss";
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 20%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
小程序引用公共页面小程序引用公共页面
1、不带参数、不带参数
首先在pages文件夹中新建一个template文件夹,文件夹中新建一个template.wxml文件,代码如下
<!--template.wxml-->
<template name="msgItem">
<view>
<text>This is template.wxml文件,我是一个模板</text>
</view>
</template>
然后我们书写我们所要调用template的页面index.wxml
<!--index.wxml-->
评论0