Vue相关

2021-04-21  本文已影响0人  Jey
  1. this.$emit失效问题
    使用小写

  2. 打开网页

// #ifdef APP-PLUS
plus.runtime.openURL(res.data.auth_url);
// #endif
                
// #ifdef H5
window.open(res.data.auth_url);
// #endif
  1. 父组件调用子组件
this.$refs.xxxx.xxxmethod()
  1. position: absolute;的用法

Relative是position的一个属性,是相对定位。
absolute是相对于自己最近的父元素来定位的,如果你不给#demo相对定位,那么#sub的绝对定位就是相对于body来定位的。

使用absolute时候,父组件用Relative

  1. hbuilderX创建的项目添加package.json
npm init
  1. 打包H5自定义路径
默认打包,production,dist/build/
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",

测试环境
"build:devh5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-build",

自定义路径
"build:prod": "cross-env NODE_ENV=production UNI_PLATFORM=h5 UNI_OUTPUT_DIR=dist/prod vue-cli-service uni-build",
"build:test": "cross-env NODE_ENV=development UNI_PLATFORM=h5 UNI_OUTPUT_DIR=dist/test vue-cli-service uni-build",
  1. 返回时候通知前一个页面
let pages = getCurrentPages(); //当前页
let beforePage = pages[pages.length - 2]; //上个页面
// #ifdef H5
beforePage.updateData()
// #endif
// #ifndef H5
beforePage.$vm.updateData()
// #endif
uni.navigateBack({
    delta: 1
})
  1. text显示最大行数
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
white-space: normal !important;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
当前页定义css参数
page {
        --itemHeight: 40px;
    }
使用
height: var(--itemHeight);
上一篇 下一篇

猜你喜欢

热点阅读