Hot answers tagged

13 votes

Vue.js search functionality

One improvement would be factoring out the repeated call to this.search.toLowerCase() and storing the result in a block-scoped constant so it: doesn't need to be ...
user avatar
9 votes
Accepted

Vue.js search functionality

It is really hard to say, but at least for me, your code is fine. It seems readable and has no issues. Perhaps if you want to change the style and make it more "canonical", you could write ...
user avatar
8 votes
Accepted

Vue - It's the Royal Game of Ur

warning: cheesy meme with bad pun below - if you don't like those, then please skip it... Question responses Do I have too many / too few components? I am aiming to make several other games in Vue ...
user avatar
8 votes

Vue.js search functionality

Another way is to create an array from name and category and combine some method with ...
user avatar
  • 553
6 votes

Vue.js search functionality

It doesn't look like this has been suggested yet but you can use object destructuring so you don't have to repeat blog a couple of times. ...
user avatar
6 votes
Accepted

Best way to do unknown number of nested v-for loops, or how to do while loops in VueJs (is there a "v-while"?)

There is no v-while, no. You can however use v-for over a computed property (which you can compute using ...
user avatar
6 votes

Vue 3 audio player

in the method getTracks(): this.tracks =response; this.tracks=response.data.tracks; No need to set ...
user avatar
5 votes
Accepted

Extracting data from vue-chartjs into an array of datasets

False alarm! No callback hell here. While this code can certainly be refactored a bit, I fail to see callback hell anywhere around. Callback hell is normally a term applied to the code that is ...
user avatar
4 votes
Accepted

Vue.js code to update selection on screen

One technique would be to apply fundamentals of event delegation by adding a method to handle all clicks. For instance, an event listener could be added to the root element (or one if child its child ...
user avatar
4 votes

Calling a global popup from nested vue components

Global Event Bus is a solution but since you have to listen emits in components's mounted or created lifecycle hook, it's getting duplicated in each instance. I had same 'issue' and resolved it by ...
user avatar
4 votes
Accepted

Display and search through a JSON's items in Vue.js

Overall the code looks fine. There aren't any drastic changes I would advise - just mostly a few simplifications. As far as the design goes it looks good, though it may be wise to add a spinner icon ...
user avatar
4 votes
Accepted

Slots and Dynamic Components

Your code is overall very neat and clean and easily readable, I think you're ready for the next level! This switch maps from one string to another: ...
user avatar
4 votes
Accepted

Passing a callback to a component in Vue.js

Your question so I've passed a callback to it. Is this okay in Vue or is there any other preferred way of structuring things like this? If you haven't already, I would suggest you read the VueJS ...
user avatar
4 votes
Accepted

Remove excessive recurrent code from store and computed

DRY the code The 3 store getters are identical apart from the filter value. So first thing is to remove the repeated code. Create a function (either in the store, or within its scope, that you pass ...
user avatar
  • 19.9k
4 votes

Vue.js search functionality

As already mentioned, the code is ok, but if you want to make it cleaner by removing code duplication, you can introduce local variables and helper functions: ...
user avatar
  • 1,537
4 votes

Structuring code logic for events on laravel controller

I'm mostly a back-end guy who fusses his way through front end code. Here's my advice: Keep the controller code as close as possible to handling the response only. Delegate the creation of objects to ...
user avatar
  • 141
4 votes

Vue.js checkout stepper

Is there any room for "shortening" the code? Shorthands Shorthands can simplify the markup. The click handlers already use the shorthand @click instead ...
user avatar
4 votes
Accepted

Vue.js checkout stepper

Using step as a property inside each step is redundant and can lead to bugs if the value is incorrect. Consider what would happen if you had this: ...
user avatar
4 votes
Accepted

Improving product configurator "algoritm"

The original Some comments on the code: ...
user avatar
4 votes
Accepted

Vue 3 audio player

Firstly, just want to say great job in creating your audio player! (I think I may have commented on one of the earlier issues you posted). Secondly there is nothing "wrong" with your code ...
user avatar
3 votes
Accepted

Card based computer game

Disclaimer: I will slip into C# syntax from time to time, as I have little direct typescript experience. I'm focusing on the principle more than the actual syntax. Class abuse This is something ...
user avatar
  • 5,397
3 votes
Accepted

HTMLAudioElement sound delay on keyboard clicks

SFC Consider using Single File Components instead of the declarative syntax you are using right now. It removes a lot of the headache of dealing with the this ...
user avatar
  • 2,597
3 votes
Accepted

Calling a global popup from nested vue components

Your solution seems to work and would not create unnecessary confusion for other developers (or yourself in six months). And even though Vuex seems overkill currently it may be beneficial later. One ...
user avatar
  • 1,094
3 votes

Dynamic List Application as first Vue.js App

Like I alluded to in my comment, I considered voting to close your question because point #8 looked like a request for help implementing code that doesn't work. Alas, I will review the working code. ...
user avatar
3 votes
Accepted

Dynamic List Application as first Vue.js App

At the moment all your current hobbies only consists of a name. I think you could use a simple string instead of wrapping it in an object (for point 8 this is not possible though, of course). No need ...
user avatar
3 votes

Present table of data, acquired from an endpoint, with option to sort by different values

I'm new to Vue myself so this may not be 100% accurate, just my own opinions. Kudos for learning and reaching out for feedback! You seem to have grokked a lot so I'm impressed. Computed properties ...
user avatar
3 votes
Accepted

Displaying a conflict marker

This post has been around for too long and I don't want it to be a zombie any longer... You haven't replied to our questions in comments but we see you have been on SE sites lately so I am going to go ...
user avatar
3 votes

Showing events on a multi room scheduler

I asked you how you would do it in jQuery and you said that you would do something like: ...
user avatar
3 votes

Class constructor with async properties set from poke-api

One thing that stood out for me is that you’re doing multiple HTTP calls to the same end-point during the constructFromApiResponse when you could just do one, i.e. ...
user avatar
  • 600
3 votes

Resizable split DIVs Vue.js

Manipulating DOM with VueJS The biggest comment I have about this code is that it modifies DOM elements using vanillaJS techniques. With VueJS, there are ways of achieving this without needing to ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible