Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Weird error #16

Closed
mel-florance opened this issue Aug 9, 2016 · 7 comments
Closed

Weird error #16

mel-florance opened this issue Aug 9, 2016 · 7 comments

Comments

@mel-florance
Copy link
Contributor

Hello,

i just tried to use the library and follow the example just as in the example, and impossible after 2 days...
I didnt try to update the library, but something is wrong with it.

Here the error i got :
[Vue warn]: Error when evaluating expression "function (){var e=this.now/1e3-this.since/1e3;if(this.maxTime&&e>this.maxTime)return clearInterval(this.interval),this.format?this.format(this.since):r(this.since);var t=e<=5?n("just now",this.currentLocale[0]):e<s?n(e,this.currentLocale[1]):e<a?n(e/s,this.currentLocale[2]):e<o?n(e/a,this.currentLocale[3]):e<u?n(e/o,this.currentLocale[4]):e<l?n(e/u,this.currentLocale[5]):e<d?n(e/l,this.currentLocale[6]):n(e/d,this.currentLocale[7]);return t}": TypeError: Cannot read property 'replace' of undefined (found in component: <timeago>)

I still can't understand what is wrong... i checked all the parameters i send to the component, and even convert my datetime into timestamp... but nothing...

It's very boring, especially for a simple component like this...

@egoist
Copy link
Owner

egoist commented Aug 9, 2016

Can you provide the steps to reproduce or a JSBin link?

@mel-florance
Copy link
Contributor Author

mel-florance commented Aug 9, 2016

Ok, i just attempted to re-create the bug on pastebin, but i cannot.
But, i found where the original error came from :

locales: { 'en-US': require('vue-timeago/locales/en-US.json') }

In the example we go this lines, which i copy/pasted without think, but when i use in code, it look like the require is not working at all, but when i use directly the array in the config it works, example :

Vue.use(VueTimeago, { name: 'timeago', locale: 'en-US', locales: { 'en-US': [ "just now", ["%s second ago", "%s seconds ago"], ["%s minute ago", "%s minutes ago"], ["%s hour ago", "%s hours ago"], ["%s day ago", "%s days ago"], ["%s week ago", "%s weeks ago"], ["%s month ago", "%s months ago"], ["%s year ago", "%s years ago"] ] } });

So maybe it comes from babel and webpack ? Or maybe just turn the locales files into a .js, and export the array ?

I dont really know why this is happening, but this is the only infos i get for now.

Thanks god, it's working now :)

Edit: here the jsbin : http://jsbin.com/viyepadure/edit?html,js,output

@egoist
Copy link
Owner

egoist commented Aug 9, 2016

Did you add a json-loader?

If something goes with your webpack there will be errors reported in the terminal.

@egoist
Copy link
Owner

egoist commented Aug 9, 2016

It sounds not bad placing locals in a .js file, I'll try that later, thx.

@cyrrill
Copy link

cyrrill commented Aug 25, 2016

Just ran into this issue, and @Masterchoc 's solution worked for me, thanks!

@fer-ri
Copy link

fer-ri commented Dec 26, 2016

@Masterchoc solution worked for me too .. thanks

@kaankilic
Copy link

@Masterchoc solution worked on my project also.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants