so basically i want to do a query using Apollo Query in Vue 2 CLI. but it is not working, i dont know what is the problem. maybe someone can help me? i have stuck for 3 hours withour any progress
here is the code
<ApolloQuery
:query="
(gql) => gql`
query MyQuery {
fasilitas {
judul
judul_second
deskripsi
foto
}
}
`
"
>
<template v-slot="{ result: { loading, error, data } }">
<div v-if="loading" class="loading apollo">Loading...</div>
<div v-else-if="error" class="error apollo">An error occurred</div>
<div v-else-if="data" class="result apollo">{{ data.fasilitas }}</div>
<div v-else class="no-result apollo">No result :(</div>
</template>
</ApolloQuery>
and here is the error
ERROR Failed to compile with 1 error 01:44:40
error in ./src/views/IndexView.vue?vue&type=template&id=78027b66&
Syntax Error: Error
at Array.forEach (<anonymous>)
at Array.forEach (<anonymous>)
at Array.forEach (<anonymous>)
ERROR in ./src/views/IndexView.vue?vue&type=template&id=78027b66& (./node_modules/#vue/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/#vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/IndexView.vue?vue&type=template&id=78027b66&)
Module build failed (from ./node_modules/#vue/vue-loader-v15/lib/loaders/templateLoader.js):
Error
at Node.initialise (D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:16016:10)
at D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:7993:51
at Array.forEach (<anonymous>)
webpack compiled with 1 error
i struggled with the same issue. you have to add the tag setup to your vue.config.js.
https://apollo.vuejs.org/guide/components/query.html#tag-setup
Related
I want to render markdown in my component, which usually can be done with the marked library which can be installed like so:
yarn add marked
and used in a component like so:
<template>
<div id="article" class="article page">
<div v-html="test"></div>
</div>
</template>
<script setup>
import marked from "marked";
const test = marked('<p>hello</p>')
</script>
But for whatever reason it throws a bunch of errors:
[Vue warn]: Unhandled error during execution of setup function
at <Article onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > >
at <RouterView>
at <App>
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core
at <Article onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > >
at <RouterView>
at <App>
[Vue Router warn]: uncaught error during route navigation:
TypeError: (0 , marked__WEBPACK_IMPORTED_MODULE_0__.default) is not a function
at setup (app.js:38984:66)
at callWithErrorHandling (app.js:25167:22)
at setupStatefulComponent (app.js:32032:29)
at setupComponent (app.js:31988:11)
at mountComponent (app.js:29911:13)
at processComponent (app.js:29886:17)
at patch (app.js:29487:21)
at ReactiveEffect.componentUpdateFn [as fn] (app.js:30096:17)
at ReactiveEffect.run (app.js:23830:29)
at callWithErrorHandling (app.js:25167:36)
Uncaught (in promise) TypeError: (0 , marked__WEBPACK_IMPORTED_MODULE_0__.default) is not a function
at setup (app.js:38984:66)
at callWithErrorHandling (app.js:25167:22)
at setupStatefulComponent (app.js:32032:29)
at setupComponent (app.js:31988:11)
at mountComponent (app.js:29911:13)
at processComponent (app.js:29886:17)
at patch (app.js:29487:21)
at ReactiveEffect.componentUpdateFn [as fn] (app.js:30096:17)
at ReactiveEffect.run (app.js:23830:29)
at callWithErrorHandling (app.js:25167:36)
Library versions used:
"vue": "^3.2.29"
"vue-loader": "^17.0.0"
"marked": "^4.0.12"
From this I figured that in verion 4 of marked instead of:
import marked from "marked";
you have to import it like so:
import { marked } from "marked";
since marked has been upgraded to version 4 upward, imported marked must be destructured
import marked from "marked"
it will solve the problem
I'm trying to use the Vuex store to hold the variable that will control whether or not the v-navigation-drawer component is open/visible. The reason is because I want to know if the nav-drawer is open from some other components and apply classes to some elements conditionally. Some code from my App.vue:
<v-navigation-drawer app v-model="this.$store.state.showNavDrawer" ...
...
<v-app-bar-nav-icon #click="toggleNavDrawer"></v-app-bar-nav-icon>
...
methods: {
toggleNavDrawer() {
this.$store.commit('toggleNavDrawer');
},
},
And in my main.js where my Vuex data is defined:
const store = new Vuex.Store({
state: {
showNavDrawer: null,
},
mutations: {
toggleNavDrawer(state) {
state.showNavDrawer = !state.showNavDrawer;
},
},
On initial page load, the screen size is respected and the nav-drawer shows/hides the way it should, but the following error shows up on the console:
[Vue warn]: Error in v-on handler: "TypeError: this is null"
found in
---> <VNavigationDrawer>
<VApp>
<App> at src/App.vue
<Root> vue.runtime.esm.js:619
TypeError: this is null
callback App.vue:17
VueJS 4
isActive VNavigationDrawer.ts:248
VueJS 7
confirmTransition vue-router.esm.js:2342
step vue-router.esm.js:1944
step vue-router.esm.js:1951
runQueue vue-router.esm.js:1955
confirmTransition vue-router.esm.js:2335
step vue-router.esm.js:1944
step vue-router.esm.js:1948
iterator vue-router.esm.js:2322
resolveAsyncComponents vue-router.esm.js:2105
iterator vue-router.esm.js:2300
step vue-router.esm.js:1947
step vue-router.esm.js:1951
runQueue vue-router.esm.js:1955
confirmTransition vue-router.esm.js:2330
transitionTo vue-router.esm.js:2203
init vue-router.esm.js:2923
beforeCreate vue-router.esm.js:1271
VueJS 4
<anonymous> main.js:42
js app.js:1113
__webpack_require__ app.js:849
fn app.js:151
1 app.js:1234
__webpack_require__ app.js:849
checkDeferredModules app.js:46
<anonymous> app.js:925
<anonymous> app.js:928
The first click of the nav-drawer control never does anything. There's no movement of the nav-drawer and there are no errors in the console. Every click after that works and shows/hides the drawer like it should, but there's an error in the console for every click:
[Vue warn]: Error in v-on handler: "TypeError: this is null"
found in
---> <VNavigationDrawer>
<VApp>
<App> at src/App.vue
<Root> vue.runtime.esm.js:619
TypeError: this is null
callback App.vue:17
VueJS 4
isActive VNavigationDrawer.ts:248
VueJS 10
toggleNavDrawer main.js:32
wrappedMutationHandler vuex.esm.js:844
commitIterator vuex.esm.js:466
commit vuex.esm.js:465
_withCommit vuex.esm.js:624
commit vuex.esm.js:464
boundCommit vuex.esm.js:409
toggleNavDrawer App.vue:157
VueJS 4
click VBtn.ts:158
VueJS 33
You cannot v-model to the vuex.
You need to use the :value="this.$store.state.showNavDrawer" prop instead. And then modify it with the #click event just the way you're doing it and you should be fine.
NB: If I were you I would give a boolean value straight away to your initial state, I don't see any point in making it null to start with.
I have a vue-cli app where I have installed a plugin:
npm i vue-mover
I have enabled this plugin in main.js
import mover from 'vue-mover'
Vue.use(mover)
And tried to use this in a component.vue
<template>
<div class="lineasMover">
<mover
target-id="MyMover"
:left-items="selectedItems"
:right-items="unselectedItems"
title-left="Available Items"
title-right="Selected Items"
moved-item-location="top | bottom"
>
</mover>
</div>
</template>
When i run my app, I'm getting this error in the browser's console:
"Uncaught ReferenceError: Sortable is not defined"
the plugin has it's code in a file called vue-mover.js, and this is the faulty code:
if (!Sortable) {
throw new Error('[vue-mover] cannot locate `Sortablejs` dependency.')
}
I have installed
npm i sortablejs
and also the vue version
npm i vue-draggable
but still get this error in console. I guess I need to enable a global "Sortable" variable that points to SortableJS, so that any plugin can use it, but I can't figure out how to achieve this.
Any ideas??
I built my custom CKEditor5 from classic edition.
git clone -b stable https://github.com/my/forked/repo
cd ckeditor5
npm install
npm run build
In my VUE2 project's main.js
import 'path/to/ckeditor5/build/editor.js'
Vue.prototype.editor = window.ClassicEditor
In my component
<template>
<div class="root">
<div class="editor></div>
</div>
</template>
<script>
export default{
mounted(){
var vm = this;
var ClassicEditor = vm.ClassicEditor;
ClassicEditor.create(vm.$el.querySelector('.editor'))
}
}
</script>
I got error when ClassicEditor.create(...):
Uncaught (in promise) TypeError: Cannot read property '0' of undefined
at Object.to (ckeditor.js?ccdb:44)
at new ea (ckeditor.js?ccdb:342)
at new Ac (ckeditor.js?ccdb:479)
at new Bc (ckeditor.js?ccdb:504)
at Eg.qc (ckeditor.js?ccdb:20)
at Eg.Vl (ckeditor.js?ccdb:20)
at new Eg (ckeditor.js?ccdb:20)
at eval (ckeditor.js?ccdb:20)
at new Promise (<anonymous>)
at Function.create (ckeditor.js?ccdb:20)
I can get the div.editor element but show the error when create editor.
This error comes from the incorrect Babel transpilation. It's tracked on both Babel side and CKEditor 5 side and hopefully will be fixed soon. We've heard about similar problems in our React integration.
https://github.com/babel/babel/issues/8913
https://github.com/facebook/create-react-app/issues/5387
https://github.com/ckeditor/ckeditor5-react/issues/41#issuecomment-428716100
I'd recommend to change the build process and to use an older version of babel for now. Or to do not transpile the code.
First of all I am new to react native platform and I am developing an app but I am facing one issue when I run my application after changes made in classes.
I am posting my logs below, Thank you for your help folks....
index.android.js (loads successfully but app do not run)
SyntaxError: Unexpected end of JSON input
at parse (<anonymous>)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
SyntaxError: Unexpected end of JSON input
at parse (<anonymous>)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
{
Error: write EPIPE
at _errnoException (util.js:1022:11)
at Socket._writeGeneric (net.js:767:25)
at Socket._write (net.js:786:8)
at doWrite (_stream_writable.js:387:12)
at writeOrBuffer (_stream_writable.js:373:5)
at Socket.Writable.write (_stream_writable.js:290:11)
at Socket.write (net.js:704:40)
at Socket.Writable.end (_stream_writable.js:553:10)
at Socket.end (net.js:496:31)
at Promise.resolve.then.then.then.catch.then.message
(E:\FinalDownload\takeawaymobileapp\node_modules\react-native\packager\src\Server\symbolicate\worker.js
:35:33) code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }