index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import ad from '../index/ad'
  2. ad({
  3. data: {
  4. value1: '1',
  5. value2: '1',
  6. value3: '1',
  7. value4: '1',
  8. value5: '1',
  9. value6: '1',
  10. options: [{ title: 'Java', value: '1' }, { title: 'PHP', value: '2' }],
  11. // options: ['1', '2'],
  12. iconPosition: 'right',
  13. },
  14. onSegmentedControlChange(e) {
  15. console.log(e)
  16. const { key, values } = e.detail
  17. const iconPosition = values[key]
  18. this.setData({
  19. iconPosition,
  20. })
  21. },
  22. onChange(field, e) {
  23. this.setData({
  24. [field]: e.detail.value,
  25. })
  26. console.log('radio发生change事件,携带value值为:', e.detail)
  27. },
  28. onChange1(e) {
  29. this.onChange('value1', e)
  30. },
  31. onChange2(e) {
  32. this.onChange('value2', e)
  33. },
  34. onChange3(e) {
  35. this.onChange('value3', e)
  36. },
  37. onChange4(e) {
  38. this.onChange('value4', e)
  39. },
  40. onChange5(e) {
  41. this.onChange('value5', e)
  42. },
  43. onItemClick(e) {
  44. const { radioRef } = e.currentTarget.dataset
  45. const ref = this.selectComponent(`#${radioRef}`)
  46. if (this.data.value6 !== ref.data.value) {
  47. this.setData({
  48. value6: ref.data.value,
  49. })
  50. }
  51. console.log('onItemClick', ref)
  52. },
  53. formSubmit(e) {
  54. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  55. },
  56. })