tab.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view class="tab-box">
  3. <view class="tab">
  4. <view v-for="(item , index) in marketTab"
  5. :class="['tab-item' , index === marketTabIndex ? 'active-tab-item' : '' ]"
  6. @click.stop="changTab(index)">
  7. {{ item }}
  8. </view>
  9. </view>
  10. <!-- <component :is="phoneLogin"/> -->
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. tabIndex: Number,
  17. default: 0
  18. },
  19. data() {
  20. return {
  21. marketTabIndex: 0,
  22. marketTab: [
  23. '手机号',
  24. '邮箱'
  25. ]
  26. };
  27. },
  28. watch: {
  29. tabIndex: {
  30. handler(newVal) {
  31. this.marketTabIndex = newVal || 0
  32. },
  33. immediate: true,
  34. deep: true
  35. },
  36. marketTabIndex: {
  37. handler(newVal, oldVal) {
  38. if (newVal !== oldVal) {
  39. this.$emit("update:tabIndex", newVal);
  40. }
  41. },
  42. immediate: true,
  43. deep: true
  44. }
  45. },
  46. methods: {
  47. // marketTabIndex = index
  48. changTab(index) {
  49. this.marketTabIndex = index
  50. // this.$emit('updata:tabIndex', index)
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. @import "~./../common.scss"
  57. </style>