Nuxt.js: Error with v-text

Created on 11 Sep 2017  路  14Comments  路  Source: nuxt/nuxt.js

When i use v-text and refresh page i get an error "Cannot read property 'replace' of undefined"

image
image

When I turn to this page with any other, then everything is ok. And when i change v-text to v-html everything is fine.

This question is available on Nuxt.js community (#c1464)
help-wanted

All 14 comments

@alexchopin I do not need help, it's a bug

Set a default value to s param:

function escape(s = "") { 
  ...
}

@NicoPennec i think you should say this to the developers nuxt, because this is not a bug in my code. As you can see, this error in node_modules folder.

vue-server-renderer module come from Vue Core: https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer

Can you share your complete components/forms/vinput.vue file? the template is truncated on your screenshoot...

@NicoPennec

vinput.vue file.

image

as I said, the problem is solved, when replacing the v-text with v-html, but still, it's a bug

It seems that the bug is probably on your side.

if errors is an empty array, then errors[0] will be undefined, because the v-if condition is true => errors is not null...

retry with v-if="errors.length" v-text="errors[0]"

@NicoPennec

Okay, but in other places where I also use v-text, I get same error. And as you wrote before, to fix this bug, you need to fix the build.js file in nuxt core and add

function escape(s = "") { 
  ...
}

@NicoPennec

And if you don't know, how Vue.js and Nuxt.js works, please don't answer. You've already recommended that I fix the file in the node_modules folder, and if i change my condition in v-if, nothing will change. Thanks.

vue-server-renderer module come from Vue Core

I think answers of @NicoPennec are in a right direction. If we ever should consider "not handling null values with v-text" directive as a bug, we need to make minimal a reproduction code and report it to the correct repository (vuejs/vue in this case) not here, as it is not directly something with Nuxt. I'll try to make a PR fix for this soon.

@Exitialis
You are right, the label "help wanted" is a not good choice for your issue.
People (like @NicoPennec) from the Vue.js/Nuxt.js community should not spent their free time to resolve your issue posted in the wrong repository.

@NicoPennec @alexchopin @pi0
I did not want to offend anyone, and I also did not know that it was a bug with vue.js, since before updating the version of Nuxt to the RC version, everything worked fine. I apologize if I offended anyone.

Closing since it's related to Vue-Server-Renderer directly (https://github.com/vuejs/vue/issues/6572), in the meantime, make sure to not use null value into v-text @Exitialis by using a computed property.

Thanks to @NicoPennec for his help on this issue.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maicong picture maicong  路  3Comments

jaredreich picture jaredreich  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

surmon-china picture surmon-china  路  3Comments

VincentLoy picture VincentLoy  路  3Comments