A select control that implements a remote request JSON based on Vue.js

Source: Internet
Author: User

Basic ideas
    • The front end takes the required parameter type encoding to the background, returns the corresponding parameter list JSON in the background, and the front end uses Vue to render the select control
Specific implementation
    • Front-end Code
<select v-model="template.type" class="form-control">      <option value="">请选择...</option> <option v-for="option in options" v-bind:value="option.macroId"> {{ option.name }} </option></select>
    • JS Call
var vm =new Vue ({data: {options: [], template: {type: null}}, methods: {gettemplatetype:  function (null, function (data) {vm.options = data;}); }}, created: function (this.gettemplatetype ();})        
    • Controller implementation
/** * 获取某个类型所有参数值,用于前台构建下拉框 * @param value * @return */@RequestMapping("/value")public List<SysMacroEntity> listMacroValue(@RequestParam String value) {return sysMacroService.listMacroValue(value);}
    • Querying SQL statements
<select id="listMacroValue" resultType="SysMacroEntity">SELECTmacro_id,name,valueFROMsys_macroWHEREtype_id =(SELECTmacro_idFROMsys_macroWHEREvalue = #{value})AND STATUS = 1ORDER BY macro_id;</select>

A select control that implements a remote request JSON based on Vue.js

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.