当前位置:网站首页>Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
2022-07-02 06:35:00 【Xiao Ming Yuan】
Preface
take weex Network loading method of fetch Simple package , Used in global components ; The basic idea :
- encapsulation fetch plug-in unit
- stay vue Register in
- Components
Plug in encapsulation
As the code shows , Pay attention to vue.mixin The method can
/** * Created by yuan on 2017/11/1. * weex Network request operation */
const BASE_URL = "http://192.168.3.16:8080"
const stream = weex.requireModule('stream')
function get(repo, callback) {
return stream.fetch({
method: 'GET',
type: 'json',
url: BASE_URL + repo
}, callback)
}
export default {
install: function (Vue, options) {
// The added content is written in this function
Vue.mixin({
methods: {
get: function (repo, callback) {
get(repo, callback)
}
}
})
}
}Register plug-ins
stay main.js (entry.js ) Register plug-ins in
import http from './service/http'
// setting http
Vue.use(http)Use
Directly in Component's methods Call in ;
this.get('/login',res=>{
})边栏推荐
- 【每日一题】写一个函数,判断一个字符串是否为另外一个字符串旋转之后的字符串。
- 一起学习SQL中各种join以及它们的区别
- Code skills - Controller Parameter annotation @requestparam
- js中正则表达式的使用
- 构建学习tensorflow
- FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
- Does the assignment of Boolean types such as tag attribute disabled selected checked not take effect?
- 广告业务Bug复盘总结
- Data science [9]: SVD (2)
- (第一百篇BLOG)写于博士二年级结束-20200818
猜你喜欢
随机推荐
web自动化切换窗口时报错“list“ object is not callable
Alibaba cloud MFA binding Chrome browser
一口气说出 6 种实现延时消息的方案
Top 10 classic MySQL errors
20210306转载如何使TextEdit有背景图片
奇葩pip install
广告业务Bug复盘总结
Find the highest value of the current element Z-index of the page
FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
一起学习SQL中各种join以及它们的区别
AtCoder Beginner Contest 253 F - Operations on a Matrix // 树状数组
递归(迷宫问题、8皇后问题)
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
Redis - hot key issues
AWD学习
Redis——大Key問題
Distributed transactions: the final consistency scheme of reliable messages
Thread hierarchy in CUDA
The Chinese word segmentation task is realized by using traditional methods (n-gram, HMM, etc.), neural network methods (CNN, LSTM, etc.) and pre training methods (Bert, etc.)
压力测试修改解决方案









