日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

uniapp云开发

發(fā)布時(shí)間:2024/1/18 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 uniapp云开发 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一、新建uniapp云開(kāi)發(fā)項(xiàng)目

右鍵新建項(xiàng)目,
勾選啟用

二、云服務(wù)空間

如果沒(méi)有的話點(diǎn)擊新建

有了云服務(wù)器點(diǎn)擊關(guān)聯(lián)即可

三、云函數(shù)

創(chuàng)建

云函數(shù)的編寫(xiě)

上傳云函數(shù)

頁(yè)面調(diào)用

四、云數(shù)據(jù)庫(kù)

創(chuàng)建云數(shù)據(jù)庫(kù)

第一次使用新建表在右側(cè)

新增數(shù)據(jù)

表結(jié)構(gòu)

下載表結(jié)構(gòu)(可選)

運(yùn)行項(xiàng)目

連接云函數(shù)

展示數(shù)據(jù)

collection中的內(nèi)容是你的數(shù)據(jù)表名

效果展示

五、數(shù)據(jù)庫(kù)的增刪改

增加數(shù)據(jù)

代碼如下

<template><view><uni-easyinput v-model="item.name" placeholder="請(qǐng)輸入用戶名"></uni-easyinput><uni-easyinput v-model="item.tel" placeholder="請(qǐng)輸入手機(jī)號(hào)"></uni-easyinput><button @click="add()">添加</button></view> </template><script>export default {data() {return {item:{name:'',tel:''}}},methods: {add(){//數(shù)據(jù)庫(kù)var db = uniCloud.database();//獲取表db.collection("concat")//執(zhí)行添加.add(this.item).then(res=>{uni.showToast({title:"添加成功"})}).catch(err=>{console.log(err)})}}} </script><style></style>

刪除數(shù)據(jù)

更改數(shù)據(jù)

update.vue 代碼如下

<template><view><uni-easyinput v-model="item.name" placeholder="請(qǐng)輸入用戶名"></uni-easyinput><uni-easyinput v-model="item.tel" placeholder="請(qǐng)輸入手機(jī)號(hào)"></uni-easyinput><button @click="update()">更新</button></view> </template><script>export default {data() {return {item:{name:'',tel:''}}},onLoad(option) {this.item = JSON.parse(option.item)},methods: {update(){//獲取itemvar item = {...this.item};delete item._id;const db = uniCloud.database();//獲取數(shù)據(jù)庫(kù)db.collection("concat").doc(this.item._id)//查詢一條.update(item).then(res=>{uni.showToast({title:"更新成功"})uni.navigateBack();}).catch(err=>{console.log(err)})}}} </script><style></style>

六、使用OpenDB表模板創(chuàng)建 數(shù)據(jù)表

例:通訊錄

點(diǎn)擊下載校驗(yàn)函數(shù)

打開(kāi)下載的通訊錄jison文件

點(diǎn)擊

第一次使用的用戶需下載

自動(dòng)生成頁(yè)面

注冊(cè)

合并文件

list.vue文件里的渲染內(nèi)容改為item.username

成功

總結(jié)

以上是生活随笔為你收集整理的uniapp云开发的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。