Yodingizda bo'lmaydigan TypeError: VueJs-da undefined xususiyatini 'olish' o'qiy olmaydi

Quyidagi kod bor

<div id="vue-instance">

</div>

JS

var vm = new Vue({
  el: '#vue-instance',
  data: {
  },
  ready:function(){
    this.loadCountries();
  },
  methods:{
        loadCountries(){
            this.$http.get('https://restcountries.eu/rest/v1/all',function(data){
                console.log(data);
          })
      }
  }
});

Yuqoridagi kodni ishga tushirganimda menga quyidagi xatolarni beradi

Undaught TypeError: Mulohazani o'qib bo'lmayapti, aniqlanmagan

Menda skripka bor

JsFiddle

Yordam juda qadrlanadi

1
@AmreshVenugopal qanday qilib jsFiddle-ga o'rnatish kerak?
qo'shib qo'ydi muallif Vikram, manba
Sizda vue-resource o'rnatilganmi va sozlanganmi?
qo'shib qo'ydi muallif Amresh Venugopal, manba
Sizda vue-resource o'rnatilganmi va sozlanganmi?
qo'shib qo'ydi muallif Amresh Venugopal, manba
qo'shib qo'ydi muallif Ranjeet, manba
qo'shib qo'ydi muallif Ranjeet, manba

7 javoblar

$http.get is from Vue Resource. Make sure you are pulling that in properly by adding vue-resource to your package.json, install it via npm install and in code:

var Vue = require('vue');

Vue.use(require('vue-resource'));

Buni fiddleda ishlatish uchun vue-resource ni qo'shishingiz kerak tashqi manbalarda va quyidagi kodlardan foydalaning:

Vue.use(VueResource)

See working demo: https://jsfiddle.net/49gptnad/187/

3
qo'shib qo'ydi
@Vikram Bu erda siz: jsfiddle.net/49gptnad/186
qo'shib qo'ydi muallif Saurabh, manba
@Vikram Sizning kodingizda bir nechta xatolik yuz berdi. Qarang: bu yerda . Har qanday so'rovda bo'lsa, menga xabar bering.
qo'shib qo'ydi muallif Saurabh, manba
buni fiddleda qanday qilish kerak? Men nima qilishni istasam, Ajax chaqiruvi boshqa usul bormi?
qo'shib qo'ydi muallif Vikram, manba
Men konsolda hali biror narsa ko'rmayapman, lekin xatoning yo'qolganini ko'rsam ham, urlni yaxshi qo'lda sinab ko'raman
qo'shib qo'ydi muallif Vikram, manba
Agar javobingizda bu linkni yangilashingiz mumkin bo'lsa, yaxshi bo'ladi. Shuning uchun uning boshqa odamlar uchun foydasi bor
qo'shib qo'ydi muallif Vikram, manba

$http.get is from Vue Resource. Make sure you are pulling that in properly by adding vue-resource to your package.json, install it via npm install and in code:

var Vue = require('vue');

Vue.use(require('vue-resource'));

Buni fiddleda ishlatish uchun vue-resource ni qo'shishingiz kerak tashqi manbalarda va quyidagi kodlardan foydalaning:

Vue.use(VueResource)

See working demo: https://jsfiddle.net/49gptnad/187/

3
qo'shib qo'ydi
@Vikram Bu erda siz: jsfiddle.net/49gptnad/186
qo'shib qo'ydi muallif Saurabh, manba
@Vikram Sizning kodingizda bir nechta xatolik yuz berdi. Qarang: bu yerda . Har qanday so'rovda bo'lsa, menga xabar bering.
qo'shib qo'ydi muallif Saurabh, manba
buni fiddleda qanday qilish kerak? Men nima qilishni istasam, Ajax chaqiruvi boshqa usul bormi?
qo'shib qo'ydi muallif Vikram, manba
Men konsolda hali biror narsa ko'rmayapman, lekin xatoning yo'qolganini ko'rsam ham, urlni yaxshi qo'lda sinab ko'raman
qo'shib qo'ydi muallif Vikram, manba
Agar javobingizda bu linkni yangilashingiz mumkin bo'lsa, yaxshi bo'ladi. Shuning uchun uning boshqa odamlar uchun foydasi bor
qo'shib qo'ydi muallif Vikram, manba

Vue-resource uchun plagin yo'q bu sizning. $ Http undefined. Vue-resursni js-fiddle-ga qo'shish uchun https://cdn.jsdelivr.net/g/[email protected],[email protected] tashqi skriptlar bo'limiga.

0
qo'shib qo'ydi

Men ushbu masalani quyidagi rejim bilan belgiladim:

npm install bootstrap-vue --save
npm install vue-resource --save

main.js saytida

import Vue from './bootstrap'
import BootstrapVue from 'bootstrap-vue'

Vue.use(BootstrapVue)

bootstrap.js yaratish

import Vue from 'vue'
import VueResource from 'vue-resource'

Vue.use(VueResource)

export { Vue }

App.vue'da

this.$http.get('/api/module/all').then(...
0
qo'shib qo'ydi

Men ushbu masalani quyidagi rejim bilan belgiladim:

npm install bootstrap-vue --save
npm install vue-resource --save

main.js saytida

import Vue from './bootstrap'
import BootstrapVue from 'bootstrap-vue'

Vue.use(BootstrapVue)

bootstrap.js yaratish

import Vue from 'vue'
import VueResource from 'vue-resource'

Vue.use(VueResource)

export { Vue }

App.vue'da

this.$http.get('/api/module/all').then(...
0
qo'shib qo'ydi

$ http dan foydalanish uchun avval vue-resource middleware dasturini o'rnatishingiz kerak. Uni o'rnatish uchun quyidagi buyruqdan foydalanishingiz mumkin.

npm install vue-resource --save

O'rnatilganidan so'ng main.js faylingizga o'ting va vue resource faylini quyidagi tarzda import qiling

import vueResource from 'vue-resource'

Endilikda uni import qilishimiz kerak, shuning uchun biz ushbu qidiruv dastur bilan ishlash uchun Vue foydalanish usulini chaqirishimiz kerak. Siz foydalanish usulini quyidagi tarzda chaqira olasiz.

Vue.use(vueResource)
0
qo'shib qo'ydi

$ http dan foydalanish uchun avval vue-resource middleware dasturini o'rnatishingiz kerak. Uni o'rnatish uchun quyidagi buyruqdan foydalanishingiz mumkin.

npm install vue-resource --save

O'rnatilganidan so'ng main.js faylingizga o'ting va vue resource faylini quyidagi tarzda import qiling

import vueResource from 'vue-resource'

Endilikda uni import qilishimiz kerak, shuning uchun biz ushbu qidiruv dastur bilan ishlash uchun Vue foydalanish usulini chaqirishimiz kerak. Siz foydalanish usulini quyidagi tarzda chaqira olasiz.

Vue.use(vueResource)
0
qo'shib qo'ydi
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb

VueJS_uz
VueJS_uz
83 ishtirokchilar

VueJS (vuejs.org) freymvorkining o'zbek tilidagi jamiyati Telegram guruhi. Boshqa guruhlar: @js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek —————— @uzdevgroup ————— @UzDev_Jobs