当前位置:网站首页>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=>{
})边栏推荐
- Sentinel Alibaba open source traffic protection component
- Uploading attachments using Win32 in Web Automation
- Sentinel rules persist to Nacos
- CUDA中的异步数据拷贝
- Eggjs -typeorm 之 TreeEntity 实战
- 一起学习SQL中各种join以及它们的区别
- Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
- TensorRT的数据格式定义详解
- 数据科学【八】:SVD(一)
- 介绍两款代码自动生成器,帮助提升工作效率
猜你喜欢

栈(线性结构)

Redis——缓存击穿、穿透、雪崩

华为MindSpore开源实习机试题

web自动中利用win32上传附件

Idea announced a new default UI, which is too refreshing (including the application link)

It is said that Kwai will pay for the Tiktok super fast version of the video? How can you miss this opportunity to collect wool?

找到页面当前元素z-index最高的数值

递归(迷宫问题、8皇后问题)

【张三学C语言之】—深入理解数据存储

Hydration failed because the initial UI does not match what was rendered on the server.问题原因之一
随机推荐
Redis - cluster data distribution algorithm & hash slot
eslint配置代码自动格式化
Name six schemes to realize delayed messages at one go
FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
Alibaba cloud MFA binding Chrome browser
kali最新更新指南
FE - weex 开发 之 使用 weex-ui 组件与配置使用
日志(常用的日志框架)
Pytest (1) case collection rules
Sentinel 阿里开源流量防护组件
Ruijie ebgp configuration case
代码技巧——Controller参数注解@RequestParam
Distributed transactions: the final consistency scheme of reliable messages
Amazon AWS data Lake Work Pit 1
selenium的web自动化中常用的js-修改元素属性翻页
浅谈三点建议为所有已经毕业和终将毕业的同学
Log (common log framework)
Summary of advertisement business bug replay
Sudo right raising
Flask-Migrate 检测不到db.string() 等长度变化