vue2

跨域设置

axios.defaults.baseURL = 'http://192.168.1.118:808';
axios.defaults.withCredentials = true;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

http://www.ituring.com.cn/article/200275

.withCredentials()方法可以激活发送原始cookie的能力,不过只有在Access-Control-Allow-Origin不是一个通配符(*),并且Access-Control-Allow-Credentials为’true’的情况下才行.

打包

http://m.blog.csdn.net/article/details?id=51322637

npm adduser

如果长时间不登录,可能会过期,使用 npm login 进行登录就可以 publish 了。

npm publish

如果使用淘宝的源(http://cnodejs.org/topic/4f9904f9407edba21468f31e),则不能使用 npm publish。 需要切回 npmjs 源: 

npm config set registry http://registry.npmjs.org/

Element-ui修改

1. 下载源码:https://github.com/ElemeFE/element

2. 参考说明:https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.zh-CN.md

3. fock

4. git pull

5. commit & push

发布自己的Vue库

以 element-ui 为基础,提交源码之后,不能马上就加入新功能。 把 element-ui 下载一份, 全局替换: element-ui  => element-ui-yxh

1. npm install

2. 修改源码,修改版本号,递增

3. npm build dist

4. npm adduser

5. npm publish

Promise.reject错误捕获

http://www.uedsc.com/296729.html

Vue2拦截器

vue2自带的拦截器,已被 axios 替代: https://github.com/mzabriskie/axios

try {
  Vue.http.interceptors.push(function (request, next) {
    // ...
    // 请求发送前的处理逻辑
    // ...

    var getFullUrl = function (url) {
      if (url.slice(0, 2) == "//") return url;

      if (url[0] != "/") {
        url = "/" + url;
      }
      return "//172.30.8.132:808" + url;
    }

    // request.method = "JSONP";
    request.url = getFullUrl(request.url);

    next(function (response) {
      if (response.status == 200) {
        if (response.body && response.body.msg) {
          this.$message.error(response.body.msg);
          return new Promise(function (resolve, reject) {
            reject(response);
          });
        }
      }
      else if (response.status == 500) {
        this.$message.error(response.body);
        // throw new Error("Error");
        return new Promise(function (resolve, reject) {
          reject(response);
        });
      }
      return;
    })
  });
} catch (e) {
  //console.info("Vue.http.interceptors:" + e.message);
}

问题

重置数据

Object.assign(this.$data,this.$options.data());

如何在运行时设置 v-model 的表达式 ?

html:

<input  ref="name" />

 

//js:像这样:

this.info.name = "OK"

this.$refs["name"].$propData["value"].express = "info.name";

获取 v-modle 表达式:

var d = VueComponent;

d.$vnode.data.model.expression

调试

https://www.zhihu.com/question/41127712/answer/252388995

devtool: '#eval-source-map'

jsx

http://blog.csdn.net/u014628388/article/details/76099812

版本

npm 组件版本真是害人啊。

https://majing.io/posts/10000022041170

No parser and no file path given, couldn't infer a parser.

升级 vue-loader 到 14.2.3+

IE11 , Symbol 未定义的错误: 

https://www.cnblogs.com/sophie_wang/p/7879918.html

安装:  es6-symbol

原文地址:https://www.cnblogs.com/newsea/p/6669589.html