参数 | 说明 | 类型 |
---|---|---|
Vue | Vue示例 | Vue |
options | Vue示例选项 | Object |
1 2 3 4 5 6 7 8 9 | // 页面初始化 在启动页面 main.js 使用 connect(Vue, { el: '#app' , // 根目录html 的 标签 router, // router路由 store, // vuex 状态管理器 components: { App }, template: '<App/>' , deviceConfig }) |
1 2 3 4 5 6 7 8 9 10 | //例子 链接: http: //test.open-iot.tmall.com:8080/#/?productKey=100658&devId=80da07c96a05&_ali_share_button_=false AI.urlParam(); // 返回 { "urlParamVal" : 3 , "productKey" : "100650" , "devId" : "80da07c969e8" , "_ali_share_button_" : "false" } |
1 | AI.goBack() |
1 2 3 4 5 6 | // 在天猫精灵使用 AI.hasNetWork().then((resp) => { console.log(resp) // 如果成功 返回wifi 名称 例:alibaba-inc }). catch ((error) => { console.log(error) // 如果在web 浏览器上使用 会报‘ 请在客户端环境调用!’ }) |
1 | AI.finishCurrentPage() // 在天猫精灵APP中使用 web 上无效 |
参数 | 说明 | 类型 |
---|---|---|
Background | 离开页面时回调 | Function |
Active | 回到页面时回调 | Function |
1 2 3 4 5 6 7 8 9 | // 监听页面改变 AI.listenPageChange({ Background: () => { // ... 离开页面 }, Active: () => { // ... 回到页面 } }) |
1 2 3 4 | beforeDestroy() { // 离开页面时 取消页面所有监听 AI.allListenRemove(); }, |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
title | 设置页面标题 | string | 设置 |
pre | 当前环境 如果是线上环境release 优先线上 如果是预发环境默认预发2 | string | 2 |
1 2 3 4 | // 前往设置页面 AI.goWeexSetPage({ title: '设置' }); |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
title | 设置页面标题 | string | 设置 |
mainPageHasSet | 首页是否展示设置按扭 flase / true | string | true |
pre | 点击默认首页右上角设置按扭,进入设备详情页面,内测debug环境 1 - 8 字符串 | string | —— |
right | 设置navbar右侧功能 | array | 右侧展示设置按扭,点击前往设备详情页(不需要展示任何,可设置[]) |
right[i].type | 图片/文字 image/text | string | —— |
right[i].content | 图片链接/展示的文字 | string | —— |
right[i].eventFunc | 兼听的点击事件 | function | —— |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // 设置navbar created() { this .$nextTick(() => { this .setNavbar(); // 设置topbar }); }, methods: { setNavbar(){ AI.setNavbar({ title: this .title, // right: [{ // type: 'image', // eventFunc: () => { // alert('you clicked on me !') // }, // }] }) } } |
1 2 3 4 | // 前往定时页面 AI.goTiming() // 注:虚拟设备无法支持该功能 |
1 2 | // 打开淘宝页面 |