更新记录

v1.0.0(2022-03-02)

首次发布


平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
app-vue app-nvue
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

使用(how to use this package)

如何使用
First, we should initialize the network module in this package in main.js file

import {network} from "net2view";  

network.init("https://127.0.0.1:8080",()=>{
    // 返回一个权限验证的键值对表达式
    // an expression that returns a pair in terms of the form for the authorization that you expect
    return {token: query("tokenid") } 
},(r)=>{
    // 判断请求是否正确的表达式
    // an expression that judges whether the request is ok
    return r.data.status === "success"; 
})

如何在组件中使用
how to use this package in your component

<template>
  <view>
     {{TryRead(list.value,"msg.data")}}
  </view>
</template>
<script setup>
import {
    hook,
    TryRead,
    hookBadModel
} from "net2view";
import {
    reactive, 
    onBeforeMount
} from "vue";

// define the event for a model
const eventDriver = reactive({  //定义事件驱动
    method:"get",
    api:"/getlist",
    update:0,
    /*
    //url参数 
    // option for parameters in url, the form should be {key:value}
    data:null,   

    // header头参数
    // option for headers in request header, the form should be {key:value}
    header:null  

    */
});

// define the model associated with the above event
const list = reactive({  //定义事件驱动
    value:{}
})

// hook的第一第二参数支持数组形式,要求事件和对应的数据模型一一对应
// the first argument can be of array type, as well as the second argument
// when they are of array type, they shall correspond   

hook(eventDriver,list,(driver,model)=>{  
      // callback for the success requests
      // 请求成功后的回调
});

hookBadModel(list,(model)=>{  

       // 监测到list对应的事件请求失败时的回调
      //hookBadModel的一个参数支持批量监测加入到hook的model

      // this will be evaluated when the event associated with "list" will fail

      // the first argument can be of array type
});

onBeforeMount(()=>{
      // 组件挂载前,驱动数据
      // drive eventDriver, which will automatically update the corresponding view.
      eventDriver.update++; 
});
/*
    // 等价于 list.value.msg.data, 前者是安全访问
    // the use of this api is equivalent to `list.value.msg.data` except that the former can safely access the data
    TryRead(list.value,"msg.data")  
*/
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问