cascader2.html 970 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <div id="{$name}">
  2. <input type="hidden" name="{$name}" value="">
  3. <el-cascader
  4. v-model="value"
  5. :options="options"
  6. :props="props"
  7. collapse-tags
  8. clearable
  9. style="width:100%"
  10. ></el-cascader>
  11. </div>
  12. <script>
  13. new Vue({
  14. el: '#{$name}',
  15. data: function() {
  16. return {
  17. props: { multiple: true },
  18. // props:{
  19. // value: 'id',
  20. // label: 'title',
  21. // children: 'child'
  22. // },
  23. options: {:json_encode($lists)},
  24. value: {:json_encode($val)}
  25. }
  26. },
  27. watch: {
  28. value: function (newVal, oldVal) {
  29. $('input[name={$name}]').val(newVal.join(','));
  30. }
  31. },
  32. created(){
  33. const vals = this.value;
  34. $('input[name={$name}]').val(vals.join(','));
  35. }
  36. })
  37. </script>