Echo problem of select value number type in Vue

Generally speaking, select needs to be echoed to be normal. Normally, as long as the echo of the corresponding value and key is written, there is no problem. However, if it is a number type, you need to pay attention!

There are two ways of writing value in option with colon and without colon

                       <a-select v-model:value="xxx">
                        <a-select-option value="60" :key="60"
                          >1m</a-select-option
                        >
                        <a-select-option value="1800" :key="1800"
                          >30m</a-select-option
                        >
                        <a-select-option value="3600" :key="3600"
                          >1h</a-select-option
                        >
                        <a-select-option value="14400" :key="14400"
                          >4h</a-select-option
                        >
                        <a-select-option value="86400" :key="86400"
                          >1d</a-select-option
                        >
                      </a-select>

In the above writing method, if the value type is string, then there is no problem.

But if it is a number, it will not be echoed.

It needs to be preceded by a colon:

                       <a-select v-model:value="xxx">
                        <a-select-option :value="60" :key="60"
                          >1m</a-select-option
                        >
                        <a-select-option :value="1800" :key="1800"
                          >30m</a-select-option
                        >
                        <a-select-option :value="3600" :key="3600"
                          >1h</a-select-option
                        >
                        <a-select-option :value="14400" :key="14400"
                          >4h</a-select-option
                        >
                        <a-select-option :value="86400" :key="86400"
                          >1d</a-select-option
                        >
                      </a-select>

In this way, it can be echoed smoothly.

[Don't panic when you encounter such a small problem, check the basic type first.

Guess you like

Origin blog.csdn.net/chhpearl/article/details/126403337