Giter Club home page Giter Club logo

question-note's Introduction

Hi How are you!

My name is HanJiangShui.

I'm a Front Programmer.And you?

Now,I work in WuXi,JiangSu,China.

My skills is Html,Css,JavaScript,Vue and MiniProgramme. I can use React and React-Native. But I'm not very proficient. At present,I'm study deeply.

Contact Me

juejin:Personal Home Page record experience 、technology etc

question-note's People

Contributors

hjskevin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

question-note's Issues

JS实现数组对象去重

`
let StaffLit = [];
let hash = {};
StaffList = StaffList.reduce(function(item, next) {
hash[next.name] ? '' : hash[next.name] = true && item.push(next);
return item;
}, []);

`

react native 开发采坑

1.react-native-swiper 安卓无法竖向滑动,iOS没有问题
解决方法:
npm i @nart/react-native-swiper --save
import Swiper from '@nart/react-native-swiper'
然后重启就可以了。

2.react-native 打包安卓apk的时候有可能会报错。常见的处理方法有:
到安卓目录下清除缓存 执行 gradlew clean 即可。

3.在react-native中对图片使用了positon:'absolute'之后,然后再给其添加onPress事件的时候在真机上无法触发事件。具体原因也没明白是什么。改用marginTop和marginLeft来实现达到定位的效果

4.在安卓真机上添加gif图片,没有效果。需要在android/app/build.gradle下添加如下依赖
// 让安卓支持gif图片显示 implementation 'com.facebook.fresco:fresco:2.2.0' implementation 'com.facebook.fresco:animated-gif:2.2.0'
这里有一个地方需要注意,添加的fresco库一定要是最新的。不然还是会没有效果。自己在其中试了好几次。

截取src后面的url地址方法

let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/gi; let arr = _detailDesc.match(srcReg); this.imgList = (arr && arr.map(item => { item = item.replace(/src=/gi, ""); item = item.replace(/\"/g, ""); if (!/\.mp4/gi.test(item)) { return resolveImg(item); } })) ||[];

element ui upload组件手动上传文件

最近再项目中用到了upload组件:需要手动上传文件,这里把一些容易出错的地方做个总结记录。
组件默认是自动上传的,如果需要手动上传需要设置如下

<el-upload class="avatar-uploader" ref="upload" :on-success="uploadSuccess" :on-change="handlePreview" :action="uploadUrl" :auto-upload="false" > <img v-if="dialogFormData.bannerPicUrl" :src="dialogFormData.bannerPicUrl" class="avatar" /> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload>
需要设置auto-upload="false"属性 。其他具体的属性方法查看官方文档

然后调用该方法即可进行手动上传文件
_that.$refs.upload.submit();
但是图片如果没有变动的话,再次点击提交是不会调用该方法的。
如果需要再提交文件成功后进行回调的话就会存在一些问题。
如果再回调中发生错误的话,修改后再进行提交的话。就会发成不触发图片上传的方法。

解决方法:我们可以加个开关来控制图片的上传。如果有图片上传就把falg设为true ,如果没有的话就设置为false。

常用的git命令行

git init //初始化git项目

git add -A //添加文件到缓存区

git commit -m "提交信息" //把文件提交到缓存区

git pull origin 分支名 //拉取远程分支的变动

git push origin 分支名 //把本地分支的内容上传到远程分支

git branch //查看本地所有分支

git branch -a //查看本地远程所有分支

git branch -r //查看远程分支

git fetch //同步远程分支的变化

git merge 分支名 //把某个分支和当前所在分支进行合并

git log //查看项目提交记录

撤销pull操作的代码
git reflog
git reset --hard {id} //id为需要回退版本的id

git暂存命令
git stash //把修改的代码存储到暂存区
git stash pop //获取暂存区的上一个版本
git stash list //获取暂存区的列表
git stash clear //清空stash栈列表
git stash apply stash@{指定版本号} //取出暂存区的制定版本

微信公众号中的图片上传问题

最近再做微信的项目。其中在调用微信图片jssdk的时候遇到一些坑:这里做下总结:方便在下次遇到的时候能很快的解决掉。

具体wxapi的调用以及使用方法我们可以看官方文档

//选择图片 chooseImg() { let _that = this; _that.sequence = 0; wx.chooseImage({ count: _that.chooseNum, // 默认9 sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有 success: function(res) { let localIdsList = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 // _that.uploadImgList = res.localIds; //用户上传 res.localIds.forEach((item, index) => { _that.uploadImgList.push(item); }); let len = localIdsList.length; _that.chooseNum = _that.chooseNum - len; _that.localIdsListAll = res.localIds; // 判断是否是ios系统 if (window.__wxjs_is_wkwebview) { _that.showImg(_that.localIdsListAll[_that.sequence]); } else { localIdsList.forEach((item, index) => { _that.imageList.push(item); }); } } }); },

这里是调用的chooseImage接口。使用方法可以参考官方文档。这里有一个要注意的就是ios和安卓的兼容问题。

在ios中接口返回的localdata数据不能直接在页面中显示出来。需要做下处理。
处理方式如下:

// 兼容ios显示图片 showImg(localId) { let _that = this; wx.getLocalImgData({ localId: localId, success: function(res) { let localData = res.localData; localData = localData.replace("jgp", "jpeg"); _that.imageList.push(localData); // localData是图片的base64数据,可以用img标签显示 _that.sequence++; let len = _that.localIdsListAll.length; if (_that.sequence <= len - 1) { _that.showImg(_that.localIdsListAll[_that.sequence]); } } }); },
还有一个要注意的就是图片在上传到微信服务器的时候只能一张一张上传。这里需要做小回调处理。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.