text-picker.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // components/text-picker/text-picker.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. options: {
  7. addGlobalClass: true,
  8. },
  9. properties: {
  10. label: {
  11. type: String,
  12. value: '',
  13. },
  14. formid: {
  15. type: String,
  16. value: '',
  17. },
  18. forminfo: {
  19. type: Object,
  20. value: {}
  21. }
  22. },
  23. behaviors: ['wx://component-export'],
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. input_text:'',
  29. hx_index:0,
  30. },
  31. //组件最终对外导出的数据
  32. export() {
  33. return {
  34. input_text: this.data.input_text,
  35. force: this.properties.forminfo.force,
  36. role: this.properties.forminfo.role }
  37. },
  38. ready:function(){
  39. let ops=this.properties.forminfo.data;
  40. this.setData({
  41. input_text:ops[0].name
  42. });
  43. },
  44. /**
  45. * 组件的方法列表
  46. */
  47. methods: {
  48. bindPickerChange:function(e){
  49. let lists=this.properties.forminfo.data;
  50. console.log(lists[e.detail.value].name)
  51. this.setData({ //给变量赋值
  52. hx_index: e.detail.value,
  53. input_text: lists[e.detail.value].name
  54. })
  55. }
  56. }
  57. })