uniapp踩坑记(不定期更新)
苍天祝我
[TOC]知乎不能用md的目录,手动截图
Vue 中使用全局变量
在 Vue 中若想定义全局变量有三种方法:
- 单独定义一个存全局变量的
common.js
, 然后export default
出去 - 在 main.js 里
Vue.prototype.xxx = yyy
,然后再每个组件里都可以通过this.xxx
来访问 - Vuex
文字太多最后添加 ... 省略号
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
scroll-view 的注意事项
<scroll-view scroll-x="true" class="scroll-view">
<view class="scroll-wrapper" v-for="xxx iof yyy"></view>
</scroll-view>
注意这里
.scroll-view{
display: flex;
flex: direction;
// 没用
}
// 正确的写法
.scroll-view {
width: 100%;
.scroll-wrapper {
display: inline-block;
margin-left: 20upx; // 单纯防止每个贴太近
}
}
跨端支持 iconfont 的方法
- 先将那个项目里的图标下载至本地
- 将 iconfont.ttf/iconfont.woff2 这个文件上传至 https://www.giftofspeed.com/base64-encoder/ 进行解码
- 修改 iconfont.css
@font-face {
font-family: "iconfont";
src:url(`data:application/x-font-woff2;charset=utf-8;base64,第二步转码的内容`) format('woff2');
}
// 下面的不用变
4.
<span class="iconfont icon-stared"></span>
<span class="iconfont">icon-stared</span>
<!-- 通过这两种方式使用 -->
5. 在 App.vue 里引用 iconfont.css 即可,即@import url("iconfont.css");
编辑于 2019-10-15 16:55