As a Developer I need a component XArray
that can edit arrays of strings.
Acceptance criteria
-
XArray
accepts array of strings in v-model - It renders each string as separate input
- When value of input is changed, it's written back to the array
- If value is empty the element is removed from array
- There is always one extra input shown, so that it is possible to add new values
- Last input is not loosing the focus on typing and new extra input is shown below it
- Examples in
App.vue
work as expected
Example
Let's say that myArray=['one', 'two']
Given Vue Template should result into Resulting HTML.
Vue Template
<XArray v-model="myArray" />
Resulting HTML
<div>
<input value="1">
<input value="2">
<input value="">
</div>
How to submit?
- Write in the comments "Challenge accepted".
- Fork stackblitz project and send a new link with your solution as a reply to your original comment.
Unit tests are good to have, but optional.
Share useful articles in the comments.
In a meantime I will start working on a tutorial and a solution. Don't miss it - subscribe to discussion and follow me.
Tips
- If you are new to Vuejs, start with tutorial
Top comments (20)
Challenge accepted
stackblitz.com/edit/vitejs-vite-j7...
Challenge accepted
stackblitz.com/edit/vitejs-vite-cw...
Challenge accepted!
Challenge Accepted
Challenge accepted
stackblitz.com/edit/vitejs-vite-fd...
Challenge Accepted
stackblitz.com/edit/vitejs-vite-tr...
Challenge accepted
stackblitz.com/edit/vitejs-vite-hq...
Challenge accepted
stackblitz.com/edit/vitejs-vite-r6...
Challenge accepted
Challenge accepted.