I’ve tried to figure out what is happening with this one particular page I have as I get a list of warnings and an error every time I load it
[Vue warn]: Unhandled error during execution of render function
at <MovieDetails id="5" onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
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/vue-next
at <MovieDetails id="5" onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView>
at <App>
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'rating')
at Proxy.render (MovieDetails.vue?e6ee:14)
at renderComponentRoot (runtime-core.esm-bundler.js?5c40:444)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4211)
at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)
at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4337)
at mountComponent (runtime-core.esm-bundler.js?5c40:4120)
at processComponent (runtime-core.esm-bundler.js?5c40:4078)
at patch (runtime-core.esm-bundler.js?5c40:3673)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4288)
at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)
5[Violation] Added non-passive event listener to a scroll-blocking <some> event. Consider marking event handler as 'passive' to make the page more responsive. See <URL>
[Violation] 'setTimeout' handler took 96ms www-embed-player.js:575
They all really make no sense to me other than the uncaught (in promise) and even that I’m very unsure about because when the page loads (the rating it says it can’t read displays as it should). Can anyone tell me what the warning mean and if there is a way to fix them? This is the only page of my project that has this issue. I’ll also leave my view here too and if someone might be able to tell my why the rating is throwing the error despite it displaying properly, that would be great!
<template>
<div class="movie-details">
<div class="route">
<h3>
<router-link to="/movies">
<span>Movies</span>
</router-link>
 / {{ movie.title }}
</h3>
</div>
<div class="flex row">
<h1>{{ movie.title }} <span class="subtitle">({{ moment(movie.releaseDate).format("YYYY") }})</span></h1>
<Button title="Edit" @btn-click="editMovie(this.id)" />
</div>
<div class="flex flex-info info">
<span class="details">{{ movie.rating.rating }}</span> |
<span class="details">{{ movie.movieLength }}</span> |
<span class="details">{{ movie.genre.genre }}</span> |
<span class="details">{{ moment(movie.releaseDate).format("D MMMM YYYY") }}</span>
</div>
<div class="youtube">
<iframe width="640" height="360" :src="videoEmbed" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="cast-crew grid">
<div class="director">
<h2>Directed By:</h2>
<router-link :to="{name: 'DirectorDetails', params: {id: movie.director.id }}">
<ListItem>
{{ movie.director.firstName }} {{ movie.director.lastName }}
</ListItem>
</router-link>
</div>
<aside class="cast">
<h2>Actors:</h2>
<div class="actors grid">
<div :key="actor.id" class="actor" v-for="actor in movie.actors">
<router-link :to="{name: 'ActorDetails', params: {id: actor.id}}">
<ListItem>
{{ actor.firstName }} {{ actor.lastName }}
</ListItem>
</router-link>
</div>
</div>
</aside>
</div>
</div>
</template>
<script>
import moment from "moment";
import Button from "@/components/Button.vue";
import ListItem from "@/components/ListItem.vue";
export default {
components: {
Button,
ListItem,
},
props: [
"id"
],
data() {
return {
movie: {},
moment,
videoEmbed: "https://www.youtube.com/embed/"
};
},
methods: {
editMovie(id) {
this.$router.push({name: "EditMovie", params: { id: id }});
},
async fetchMovie(id) {
const res = await fetch(`api/movies/${id}`);
const data = await res.json();
return data;
}
},
async created() {
this.movie = await this.fetchMovie(this.id);
//eslint-disable-next-line
const reg = new RegExp('.*?=s*(.*)');
const split = reg.exec(this.movie.trailerUrl);
this.videoEmbed += split[1];
}
}
</script>
<style scoped>
h1 {
font-weight: bold;
}
.subtitle {
font-weight: 400;
font-size: 1rem;
}
.info {
font-weight: 300;
letter-spacing: 1px;
}
.details {
margin: 0 0.8rem;
}
.details:first-child {
margin-left: 0;
}
.details:last-child {
margin-right: 0;
}
.youtube {
margin: 1.5rem 0;
display: flex;
}
.youtube iframe {
justify-self: flex-start;
border-radius: 8px;
}
.cast-crew {
height: 110%;
}
.cast-crew.grid {
grid-template-columns: auto 75%;
}
.cast-crew a {
font-weight: bold;
font-size: 1.125rem;
}
.director {
align-self: flex-start;
text-align: left;
}
.cast {
padding-left: 1.5rem;
text-align: left;
border-left: 2px solid #000;
align-self: flex-start;
}
.actors.grid {
grid-template-rows: repeat(4, 1fr);
grid-template-columns: auto;
gap: 0.75rem;
grid-auto-flow: column;
justify-content: flex-start;
}
</style>
#javascript #vue.js #vuejs3
#язык JavaScript #vue.js #vuejs3
Вопрос:
Я попытался выяснить, что происходит с этой конкретной страницей, поскольку каждый раз, когда я ее загружаю, я получаю список предупреждений и сообщение об ошибке
[Vue warn]: Unhandled error during execution of render function at lt;MovieDetails id="5" onVnodeUnmounted=fnlt;onVnodeUnmountedgt; ref=Reflt; undefined gt; gt; at lt;RouterViewgt; at lt;Appgt; [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/vue-next at lt;MovieDetails id="5" onVnodeUnmounted=fnlt;onVnodeUnmountedgt; ref=Reflt; undefined gt; gt; at lt;RouterViewgt; at lt;Appgt; Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'rating') at Proxy.render (MovieDetails.vue?e6ee:14) at renderComponentRoot (runtime-core.esm-bundler.js?5c40:444) at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4211) at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160) at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4337) at mountComponent (runtime-core.esm-bundler.js?5c40:4120) at processComponent (runtime-core.esm-bundler.js?5c40:4078) at patch (runtime-core.esm-bundler.js?5c40:3673) at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4288) at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160) 5[Violation] Added non-passive event listener to a scroll-blocking lt;somegt; event. Consider marking event handler as 'passive' to make the page more responsive. See lt;URLgt; [Violation] 'setTimeout' handler took 96ms www-embed-player.js:575
Все они действительно не имеют для меня никакого смысла, кроме неучтенного (в обещании), и даже в этом я очень не уверен, потому что при загрузке страницы (рейтинг, в котором говорится, что она не может читать, отображается так, как должно). Может ли кто-нибудь сказать мне, что означает это предупреждение и есть ли способ их исправить? Это единственная страница моего проекта, на которой есть эта проблема. Я также оставлю здесь свое мнение, и если кто-нибудь сможет объяснить мне, почему рейтинг выдает ошибку, несмотря на то, что она отображается правильно, это было бы здорово!
lt;templategt; lt;div class="movie-details"gt; lt;div class="route"gt; lt;h3gt; lt;router-link to="/movies"gt; lt;spangt;Movieslt;/spangt; lt;/router-linkgt; amp;emsp;/amp;emsp;{{ movie.title }} lt;/h3gt; lt;/divgt; lt;div class="flex row"gt; lt;h1gt;{{ movie.title }} lt;span class="subtitle"gt;({{ moment(movie.releaseDate).format("YYYY") }})lt;/spangt;lt;/h1gt; lt;Button title="Edit" @btn-click="editMovie(this.id)" /gt; lt;/divgt; lt;div class="flex flex-info info"gt; lt;span class="details"gt;{{ movie.rating.rating }}lt;/spangt; | lt;span class="details"gt;{{ movie.movieLength }}lt;/spangt; | lt;span class="details"gt;{{ movie.genre.genre }}lt;/spangt; | lt;span class="details"gt;{{ moment(movie.releaseDate).format("D MMMM YYYY") }}lt;/spangt; lt;/divgt; lt;div class="youtube"gt; lt;iframe width="640" height="360" :src="videoEmbed" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreengt;lt;/iframegt; lt;/divgt; lt;div class="cast-crew grid"gt; lt;div class="director"gt; lt;h2gt;Directed By:lt;/h2gt; lt;router-link :to="{name: 'DirectorDetails', params: {id: movie.director.id }}"gt; lt;ListItemgt; {{ movie.director.firstName }} {{ movie.director.lastName }} lt;/ListItemgt; lt;/router-linkgt; lt;/divgt; lt;aside class="cast"gt; lt;h2gt;Actors:lt;/h2gt; lt;div class="actors grid"gt; lt;div :key="actor.id" class="actor" v-for="actor in movie.actors"gt; lt;router-link :to="{name: 'ActorDetails', params: {id: actor.id}}"gt; lt;ListItemgt; {{ actor.firstName }} {{ actor.lastName }} lt;/ListItemgt; lt;/router-linkgt; lt;/divgt; lt;/divgt; lt;/asidegt; lt;/divgt; lt;/divgt; lt;/templategt; lt;scriptgt; import moment from "moment"; import Button from "@/components/Button.vue"; import ListItem from "@/components/ListItem.vue"; export default { components: { Button, ListItem, }, props: [ "id" ], data() { return { movie: {}, moment, videoEmbed: "https://www.youtube.com/embed/" }; }, methods: { editMovie(id) { this.$router.push({name: "EditMovie", params: { id: id }}); }, async fetchMovie(id) { const res = await fetch(`api/movies/${id}`); const data = await res.json(); return data; } }, async created() { this.movie = await this.fetchMovie(this.id); //eslint-disable-next-line const reg = new RegExp('.*?=s*(.*)'); const split = reg.exec(this.movie.trailerUrl); this.videoEmbed = split[1]; } } lt;/scriptgt; lt;style scopedgt; h1 { font-weight: bold; } .subtitle { font-weight: 400; font-size: 1rem; } .info { font-weight: 300; letter-spacing: 1px; } .details { margin: 0 0.8rem; } .details:first-child { margin-left: 0; } .details:last-child { margin-right: 0; } .youtube { margin: 1.5rem 0; display: flex; } .youtube iframe { justify-self: flex-start; border-radius: 8px; } .cast-crew { height: 110%; } .cast-crew.grid { grid-template-columns: auto 75%; } .cast-crew a { font-weight: bold; font-size: 1.125rem; } .director { align-self: flex-start; text-align: left; } .cast { padding-left: 1.5rem; text-align: left; border-left: 2px solid #000; align-self: flex-start; } .actors.grid { grid-template-rows: repeat(4, 1fr); grid-template-columns: auto; gap: 0.75rem; grid-auto-flow: column; justify-content: flex-start; } lt;/stylegt;
Ответ №1:
Используйте метод lodash get
для исправления неопределенной ошибки
lt;scriptgt; import _ from 'lodash'; export default { methods: { getValue(object, string, defaultValue = ''): { return _.get(object, string, defaultValue) } } lt;/scriptgt; lt;templategt; {{ getValue(movie, 'rating.rating') }} lt;/templategt;
вы можете сделать его глобальным помощником для последующего использования в шаблоне
I’m trying to make an online store on vue.And I got three errors that I can’t fix:
1)[Vue warn]: Property «$store» was accessed during render but is not defined on instance.
2)[Vue warn]: Unhandled error during execution of render function
3)Uncaught TypeError: Cannot read properties of undefined (reading ‘getters’)
Store.js
import { createStore } from 'vuex'
import axios from "axios";
const store = createStore({
state:{
products:[]
},
mutations:{
SET_PRODUCTS_TO_STATE:(state,products)=>{
state.products = products;
}
},
actions:{
GET_PRODUCTS_FROM_API({commit}) {
return axios('http://localhost:3000/products',{
method:"GET"
})
.then((products) =>{
commit('SET_PRODUCTS_TO_STATE',products.data);
return products;
})
.catch((error)=>{
console.log(error)
return error;
})
}
},
getters:{
PRODUCTS(state){
return state.products;
}
}
});
export default store;
v-catalog.vue
<template>
<div class = 'v-catalog'>
<h1>Catalog</h1>
<div class ="v-catalog__list">
<v-catalog-item
v-for="product in PRODUCTS"
:key="product.article"
v-bind:product_data="product"
@sendArticle="showChildArticleInConsole"
/>
</div>
</div>
</template>
<script>
import VCatalogItem from "@/components/v-catalog-item";
import {mapActions,mapGetters} from 'vuex'
export default {
name: "v-catalog",
components:{
VCatalogItem
},
props:{},
data(){
return{
}
},
computed:{
...mapGetters([
'PRODUCTS'
]),
},
methods: {
...mapActions([
'GET_PRODUCTS_FROM_API'
]),
showChildArticleInConsole(data){
console.log(data);
},
mounted(){
this.GET_PRODUCTS_FROM_API()
.then((response)=> {
if (response.data) {
console.log('Data here')
}
})
}
}
}
</script>
main.js
import { createApp } from 'vue'
import App from './App.vue'
import './assets/Styles/styles.scss'
import store from "./vuex/store";
const app = createApp(App)
app.use(store)
createApp(App).mount('#app')
Я пытался выяснить, что происходит с этой конкретной страницей, поскольку я получаю список предупреждений и ошибок каждый раз, когда загружаю ее.
[Vue warn]: Unhandled error during execution of render function
at <MovieDetails id="5" onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
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/vue-next
at <MovieDetails id="5" onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView>
at <App>
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'rating')
at Proxy.render (MovieDetails.vue?e6ee:14)
at renderComponentRoot (runtime-core.esm-bundler.js?5c40:444)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4211)
at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)
at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4337)
at mountComponent (runtime-core.esm-bundler.js?5c40:4120)
at processComponent (runtime-core.esm-bundler.js?5c40:4078)
at patch (runtime-core.esm-bundler.js?5c40:3673)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4288)
at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)
5[Violation] Added non-passive event listener to a scroll-blocking <some> event. Consider marking event handler as 'passive' to make the page more responsive. See <URL>
[Violation] 'setTimeout' handler took 96ms www-embed-player.js:575
Все они на самом деле не имеют для меня никакого смысла, кроме непойманного (в обещании), и даже в этом я очень не уверен, потому что, когда страница загружается (рейтинг говорит, что он не может читать, отображается так, как должен). Может ли кто-нибудь сказать мне, что означают предупреждения и есть ли способ их исправить? Это единственная страница моего проекта, на которой есть эта проблема. Я также оставлю здесь свое мнение, и если кто-то сможет сказать мне, почему рейтинг выдает ошибку, несмотря на то, что он отображается правильно, это было бы здорово!
<template>
<div class="movie-details">
<div class="route">
<h3>
<router-link to="/movies">
<span>Movies</span>
</router-link>
 / {{ movie.title }}
</h3>
</div>
<div class="flex row">
<h1>{{ movie.title }} <span class="subtitle">({{ moment(movie.releaseDate).format("YYYY") }})</span></h1>
<Button title="Edit" @btn-click="editMovie(this.id)" />
</div>
<div class="flex flex-info info">
<span class="details">{{ movie.rating.rating }}</span> |
<span class="details">{{ movie.movieLength }}</span> |
<span class="details">{{ movie.genre.genre }}</span> |
<span class="details">{{ moment(movie.releaseDate).format("D MMMM YYYY") }}</span>
</div>
<div class="youtube">
<iframe width="640" height="360" :src="videoEmbed" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="cast-crew grid">
<div class="director">
<h2>Directed By:</h2>
<router-link :to="{name: 'DirectorDetails', params: {id: movie.director.id }}">
<ListItem>
{{ movie.director.firstName }} {{ movie.director.lastName }}
</ListItem>
</router-link>
</div>
<aside class="cast">
<h2>Actors:</h2>
<div class="actors grid">
<div :key="actor.id" class="actor" v-for="actor in movie.actors">
<router-link :to="{name: 'ActorDetails', params: {id: actor.id}}">
<ListItem>
{{ actor.firstName }} {{ actor.lastName }}
</ListItem>
</router-link>
</div>
</div>
</aside>
</div>
</div>
</template>
<script>
import moment from "moment";
import Button from "@/components/Button.vue";
import ListItem from "@/components/ListItem.vue";
export default {
components: {
Button,
ListItem,
},
props: [
"id"
],
data() {
return {
movie: {},
moment,
videoEmbed: "https://www.youtube.com/embed/"
};
},
methods: {
editMovie(id) {
this.$router.push({name: "EditMovie", params: { id: id }});
},
async fetchMovie(id) {
const res = await fetch(`api/movies/${id}`);
const data = await res.json();
return data;
}
},
async created() {
this.movie = await this.fetchMovie(this.id);
//eslint-disable-next-line
const reg = new RegExp('.*?=s*(.*)');
const split = reg.exec(this.movie.trailerUrl);
this.videoEmbed += split[1];
}
}
</script>
<style scoped>
h1 {
font-weight: bold;
}
.subtitle {
font-weight: 400;
font-size: 1rem;
}
.info {
font-weight: 300;
letter-spacing: 1px;
}
.details {
margin: 0 0.8rem;
}
.details:first-child {
margin-left: 0;
}
.details:last-child {
margin-right: 0;
}
.youtube {
margin: 1.5rem 0;
display: flex;
}
.youtube iframe {
justify-self: flex-start;
border-radius: 8px;
}
.cast-crew {
height: 110%;
}
.cast-crew.grid {
grid-template-columns: auto 75%;
}
.cast-crew a {
font-weight: bold;
font-size: 1.125rem;
}
.director {
align-self: flex-start;
text-align: left;
}
.cast {
padding-left: 1.5rem;
text-align: left;
border-left: 2px solid #000;
align-self: flex-start;
}
.actors.grid {
grid-template-rows: repeat(4, 1fr);
grid-template-columns: auto;
gap: 0.75rem;
grid-auto-flow: column;
justify-content: flex-start;
}
</style>
1 ответ
Используйте метод lodash get
для исправления неопределенной ошибки.
<script>
import _ from 'lodash';
export default {
methods: {
getValue(object, string, defaultValue = ''): {
return _.get(object, string, defaultValue)
}
}
</script>
<template>
{{ getValue(movie, 'rating.rating') }}
</template>
Вы можете сделать его глобальным помощником для использования позже в шаблоне
1
Sovai
9 Дек 2021 в 07:46
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.