android stuido 安装后的配置

dvm 设备无法访问的解决办法

在 linux 中使用 android stuido dvm 添加虚拟机,可能会出现 /dev/kvm 无法访问的问题,解决办法如下:

首先 kvm 一定要安装,安装方法:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ia32-libs-multiarch

然后添加对 /etc/kvm 的访问权限:

# 将 username 改为自己登录的账号名
sudo adduser username kvm

注销系统,再次尝试,应该就可以了。

visual studio code 安装 source code pro

source code pro 是谷歌和adobe联合开发的适用于编程开发时使用的开源字体。

下载

到 github 找到该项目,下载该字体(所有 otf 文件)。

安装

linux 系统下载到 ~/.local/share/fonts 目录,windows 直接右键安装。

使用

在 vscode 中选择菜单 文件->首选项->设置,在 用户设置->文本编辑器->字体->Font Family 中,头部插入 'Source Code Variable', 'Source Code Variable Italic',

Linux下进行微信小程序开发

微信开发者工具本质是nw.js,可以移植到 Linux,但是需要 wine 来编译wxml和wxss的wcc和wcsc。

安装wine

  1. 安装:
sudo apt-get install wine
  1. 检查版本:
wine --version
  1. 检查配置
winecfg

安装wine-binfmt

sudo apt-get install wine-binfmt
sudo update-binfmts --import /usr/share/binfmts/wine

安装微信开发工具

git clone https://github.com/cytle/wechat_web_devtools.git
cd wechat_web_devtools
./bin/wxdt install  # 自动下载最新的nw.js,同时部署目录 ~/.config/微信web开发者工具/

常见问题

ERROR:sandbox_linux.cc(370)] InitializeSandbox() called with multiple threads in process gpu-process.
buffer_manager.cc(488)] [.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

上面两个问题,是因为配置中使用了gpu导致的,所以在启动时强制执行不使用gpu就可以正常运行

./bin/wxdt --disable-gpu

使用 phpstorm 开发微信小程序

让 phpstorm 实现代码高亮,代码提示。

代码高亮

  1. 打开配置界面,找到:editorfile types
  2. 找到 Cascading Style Sheet,添加 *.wxss
  3. 找到 HTML,添加 *.wxml

Live Templates

  1. 下载wecharCode.jar 到本地
  2. 在菜单 Fileimport settings 中导入

使用 vuex 的 mapState

在 vue 中:

<template>
  <div>
    {{user.name}}
  </div>
</template>

<script>
import {mapState} from 'vuex';

export default {
  computed: {
    ...mapState({
      user: state => state.user
    })
  }
}
</script>

在 store 中:

export default {
    state: {
        user: {}
    },
}

继续阅读

js删除数组里的某个元素

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};
// 移除数组中的第二项
array.remove(1);
// 移除数组中的倒数第二项
array.remove(-2);
// 移除数组中的第二项和第三项(从第二项开始,删除2个元素)
array.remove(1,2);
// 移除数组中的最后一项和倒数第二项(数组中的最后两项)
array.remove(-2,-1);

来自 jQuery 之父的 stackoverflow