zoukankan      html  css  js  c++  java
  • vue-cli填坑之路

    Vue 引入jquery 

    1,npm install jquery –save-dev

    2,在build 找到 webpack.base.conf.js

           添加一个对象

           var webpack = require(‘webpack’);

           module.exports 最后添加

    // 增加一个plugins

      plugins: [

        new webpack.ProvidePlugin({

          $: "jquery",

          jQuery: "jquery"

        })

      ]

    3,在main.js中引入 $

    import $ from ‘jquery’

    如果不想使用规格检查:

    在webpack.base.conf.js 中 注释掉包含eslint-loader的部分

    vue模板中的table 中必须加<thead></thead>  <tbody></tbody>标准化

    vue-cli 引入axios

    一、npm 安装axios,文件根目录下安装,指令如下

     npm install axios --save-dev

    二、修改原型链,在main.js中引入axios

    import axios from 'axios'

    接着将axios改写为Vue的原型属性,

    Vue.prototype.$http=axios

    这样之后就可在每个组件的methods中调用$http命令完成数据请求

    三、在组件中使用

    1. methods: {
    2.       get(){
    3.         this.$http({
    4.           method:'get',
    5.           url:'/url',
    6.           data:{}
    7.         }).then(function(res){
    8.           console.log(res)
    9.         }).catch(function(err){
    10. console.log(err)
    11. })
    12. this.$http.get('/url').then(function(res){
    13. console.log(res)
    14. }).catch(function(err){
    15. console.log(err)
    16. })
    17. }    

    19.}             

  • 相关阅读:
    程序员常用字体(vs2008字体修改方案)
    Struts 与 Velocity 的集成
    CheckBox Button
    WINDOWS MOBILE winnet开发心得
    Change background color of a UIAlertView
    Windows Mobile 自定义控件(一)
    ZNLog
    获取磁盘空间大小
    iPhone开发:UIImage的一系列操作
    Windows Mobile 自定义控件(二)
  • 原文地址:https://www.cnblogs.com/vsmart/p/9324619.html
Copyright © 2011-2022 走看看