warpcgd / vue-tantan-stack

vue-tantan-stack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于文件引用丢失问题

Boxser567 opened this issue · comments

不论是 npm 、cnpm 、yarn、都不能下载全依赖,导致你的项目根本无法本地运行:
npm ERR! 403 Forbidden: vue-hot-reload-api@^1.2.0
或者
Error: GET http://registry.npm.taobao.org/karma-mocha/download/karma-mocha-0.2.2.tgz response 403 status
或者直接引用组件到项目,会报错:

vue.esm.js?efeb:591 [Vue warn]: Error in render: "TypeError: Cannot read property 'offsetWidth' of undefined" found in ---> <Stack> <Found> at src/views/Found/Found.vue <ViewBox> at node_modules/vux/src/components/view-box/index.vue <App> at src/App.vue <Root>

so,what should I do ?

引用错误的问题先不谈,直接解决抛错问题:
let width = this.$el.offsetWidth;
let height = this.$el.offsetHeight;
改成
let width = this.$el ? this.$el.offsetWidth : 0;
let height = this.$el ? this.$el.offsetHeight : 0;
稍微做个判断吧~~

然后,web端的动效还不错,移动端的就显得比较滞后了,希望拖动的时候可以增加一个遮罩,比较有层次感;

@warpcgd 按照你的写法吧 、移动端确实没有效果、、、:
`touchstart(e) {
...
this.temporaryData.offsetY = e.targetTouches[0].offsetY

}`

移动端 e.targetTouches[0].offsetY 没有这个属性 是拿不到值的,写上去直接是个 undefined,但是控制台没有任何报错,这个数值主要控制移动端滑动的offsetY样式计算,建议跟我一样渣渣的们直接将 e.targetTouches[0].offsetY 改成具体数值 45 或者任意数值,可以和web端达到一样的效果噢,自己调试。

好久没看过这个项目了,依赖应该需要更新一波,等会我看看
e.targetTouches[0].offsetY,这个移动端也是有的