How to generate nestable dropdown select box

I have a category table like this

id      name      parent_id   
1       Test         0
2       Test1       1
3       Test2       2
4       Test3       2
5       Test4       0

Now i need to generate select box like this

<select v-model="selected">
<option value="1">Test</option>
<option value="2">-Test1</option>
<option value="3">--Test2</option>
<option value="4>--Test3</option>
<option value="5>Test5</option>

Let’s say you have categories object in data:

<select v-model="selected">
<option v-for="eachCategory in categories"  :value=""> {{}} </option>

I know this, my concern is how to generate this type of dropdown using view. I have already display the dropdown but order is not working properly.