Skip to content

Uniapp

🖥️+🧔=🧑‍🦲 实际项目总结,可能你会有点看不明白,不会就问

token里的值赋值给input中的value中

js
onShow() {
			this.conf.getToken(res => {
				this.usersInfo = res;
				this.updateFFMValue(); //cs
			}, e => {
				if (!e) {
					this.usersInfo = '';
				}
			});
		},
js
updateFFMValue() {
				if (this.usersInfo.info !== '') {
					this.ffM.value = this.usersInfo.info;
				}
			},

图标

vue
<uni-icons custom-prefix="custom-icon" type="icon-youxi" size="30"></uni-icons>

在 UniApp 中使用 uni.navigateBack() 方法来关闭当前页面并返回上一页

vue
<template>
  <view>
    <!-- 点击按钮触发返回操作 -->
    <button @click="goBack">返回上一页</button>
    
    <!-- 页面其他内容 -->
  </view>
</template>

<script>
export default {
  methods: {
    goBack() {
      uni.navigateBack({
        delta: 1, // 返回上一页
      });
    },
  },
};
</script>

点击跳转

vue
<template>
<view @click="toReg()">分享码</view>
</template>
<script>
export default {
  methods: {

    toReg() {
      uni.navigateTo({
        url: "/pages/login/register",
      });
    },
    
  },
};
</script>

uni.switchTab({
	 url: '/pages/user/user'
})

渐变

css
background: linear-gradient(to right, #B666E1,#9E6BF6);

URL报错信息显示

js
if (res.data.error == '1') {
    this.conf.uaMsg(res.data.msg);
    return;
}

首页公告

vue
<!-- 公告 -->
<view class="pt15">
	<cc-noticeBar :noticeList="noticeList"></cc-noticeBar>
</view>
js
import ccNoticeBar from '@/components/cc-noticeBar/cc-noticeBar.vue'
	export default {
		 components:{ccNoticeBar},
		data() {
			return {
				noticeList: [
					// {id: 1,title: '征程这些伟大精神 串连起中国共产党人的精神谱系'},
					// {id: 2,title: '增强水运发展新动能 前5月港口货物吞吐量增长7.9%'},
					// {id: 3,title: '多地持续高温 各地采取措施积极应对'},
					// {id: 4,title: '中非经贸博览会见证中非合作深度'},
					// {id: 5,title: '国安家安得民心 保驾护航促治兴'}
				],
			}
		},
        onLoad() {
			this.getNewList();
		},
    }
js
getNewList(){
				this.conf.http('/api/pub/news/getList',this.fff,res => { 
					this.noticeList = res.data.data;
				});
			},

点击复制

js
btn_copy(){
    uni.showToast({title: "复制成功",icon: "none"});
    uni.setClipboardData({
   		 data: this.dataList.invite,
    });
},

修改页面title

js
uni.setNavigationBarTitle({title: "小俊俊"});

缓存

js
存入缓存: uni.setStorageSync("KK", res.data.data);
读取缓存: uni.getStorageSync("KK")

Released under the MIT License.