当前位置:网站首页>uniapp开发小程序如何使用微信云托管或云函数进行云开发
uniapp开发小程序如何使用微信云托管或云函数进行云开发
2022-07-07 01:43:00 【Aasee.】
一. 申请微信云托管
这个不用说吧必须的,官方地址在这。直接进去申请就行。
但是前提是你得会创建docker file,学习掌握一些基本的docker知识,会让你创建环境变得简单一点。环境创建完成之后就能进行下面的操作了。
二. 先创建一个cloudfunctions文件夹

像这样,在里面放一空文件就行什么js啊css什么的都行,这样才能进行后续的拷贝。
配置路径
然后我们就可以去uniapp里的manifest.json文件里配置cloudfunctions文件夹的位置了,以我这为例子就是
"cloudfunctionRoot": "cloudfunctions/"

因为uniapp不会将这个文件编译到mp-weixin平台,所以这里我们把它拷贝过去。这里我也是参考了这篇文章的代码。先下载一个插件。
npm install -save [email protected]
下载完成后在vue.config.js文件中进行如下配置
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
configureWebpack: {
plugins: [
new CopyWebpackPlugin([
{
from: path.join(__dirname, 'cloudfunctions'),
to: path.join(__dirname, 'try-music/dist', process.env.NODE_ENV === 'development' ? 'dev' : 'build', process.env.UNI_PLATFORM, 'cloudfunctions')
}
])
]
}
}
找到uniapp中创建的文件编译到相应环境下的包内。
这个大家应该知道路径吧。
把你们自己的路径对应写上就行。
三. 初始化,然后就能调用了。
一.初始化
在App.vue文件中的onLounch中加入
这个直接在微信官方文档也能查看。
二 .调用方法

到这里你就可以直接在uniapp中使用微信云托管服务了,当然如果实在觉得麻烦你也可以直接使用开通https的服务器进行使用,也可以使用uniapp官方推荐的unicloud服务。
边栏推荐
- 可极大提升编程思想与能力的书有哪些?
- vim映射大K
- Detailed explanation of platform device driver architecture in driver development
- How to keep accounts of expenses in life
- Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
- 基本Dos命令
- JVM命令之 jstat:查看JVM統計信息
- 谷歌 Chrome 浏览器发布 103.0.5060.114 补丁修复 0-day 漏洞
- Subghz, lorawan, Nb IOT, Internet of things
- go-microservice-simple(2) go-Probuffer
猜你喜欢

绕过open_basedir

On the discrimination of "fake death" state of STC single chip microcomputer

CTFshow--常用姿势

3531. Huffman tree

2022Android面试必备知识点,一文全面总结

From "running distractor" to data platform, Master Lu started the road of evolution

JVM monitoring and diagnostic tools - command line

How to keep accounts of expenses in life
![[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core](/img/fc/5162bbb0746f8af2d6c7d63ade571a.png)
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core

DC-7靶机
随机推荐
JVM命令之- jmap:导出内存映像文件&内存使用情况
ML's shap: Based on the adult census income binary prediction data set (whether the predicted annual income exceeds 50K), use the shap decision diagram combined with the lightgbm model to realize the
window下面如何安装swoole
[InstallShield] Introduction
c语言面试写一个函数在字符串N中查找第一次出现子串M的位置。
Dc-7 target
A very good JVM interview question article (74 questions and answers)
Redisl garbled code and expiration time configuration
jvm命令之 jcmd:多功能命令行
Ideas of high concurrency and high traffic seckill scheme
解决pod install报错:ffi is an incompatible architecture
Experience of Niuke SQL
Redis(一)——初识Redis
From "running distractor" to data platform, Master Lu started the road of evolution
软件测试的几个关键步骤,你需要知道
JVM命令之 jstack:打印JVM中线程快照
Career experience feedback to novice programmers
JMeter's own functions are not enough? Why don't you develop one yourself
安装VMmare时候提示hyper-v / device defender 侧通道安全性
JVM monitoring and diagnostic tools - command line