Vue CLI中使用jQuery

{{ time }}

Step1 在项目目录输入如下指令,以安装jQuery

npm i jquery

Step2 使用示例代码如下

<script>
//如在App.vue中
import $ from 'jquery'

export default {
  name: 'app',
  mounted: function () {
    this.get_user()
  },
  methods: {
    get_user: function () {
      $.get('http://api.domain.com/v1/user/100', {}, function (res) {
        console.log(res)
      })
    },
  },
}
</script>