我想用vue写checkbox.radio,这个怎么做呢
vue版本2.X
java springmvc
正常情况下会生成如下格式
1 2 3 4 |
|
一般情况下数据库里面放的是状态码 1,2。
而前台展示的时候显示的是值1,值2。
我如何直接输出值1,值2呢,我不想在后台进行值查询可以吗?
以前的JSP都是写个tag,直接把值转成html,现在vue我不知道怎么办了
高洛峰2017-04-18 10:54:28
First of all, thank you for the invitation.
According to your description, you want to save only the status value in the background, and then store the content corresponding to the status value in a corner of js. When you need to render, you can take out the corresponding content and render it to the page based on the corresponding status value
Since this is usually a background return, you may be able to do this depending on your needs
First in the data (or write a store file to specifically store these contents in order)
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Then you can write a status value in the data to accept the status value sent from the background
1 2 3 4 5 |
|
Render effects on the page based on these
1 2 3 |
|
Final effect
However, this is not a good idea, because for arrays, indexes can only be numbers, which limits the type of state values. The above is a solution.
So considering the diversification of state values, what should we do? Let’s talk about converting arrays into objects
Change the above first step to the form of key-value pairs
1 2 3 4 5 6 7 8 9 10 11 12 |
|
If you write it like this, the status value that we originally passed can only be of numeric type can be naturally changed into
1 2 3 4 5 |
|
This also ensures the diversity of status values.
提供一些新的思路
阿神2017-04-18 10:54:28
Thanks for the invitation.
The question you asked is unprofessional... Your title is asking about checkbox.radio, but the code in the content is a select drop-down box.
And this is a very basic question.
If value 1 and value 2 are provided by the background, how could you not query them?
In fact, the principle is the same. After you request the data from the background at the front end, you can then render the page.