New file |
| | |
| | | /** |
| | | * CAnchor - 应用内超连接 |
| | | * @author Tevin |
| | | */ |
| | | |
| | | <template> |
| | | <view |
| | | class="c-anchor" |
| | | @tap="evt => handleGoTo()" |
| | | > |
| | | <slot /> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import Taro from '@tarojs/taro'; |
| | | |
| | | export default { |
| | | name: 'CAnchor', |
| | | props: { |
| | | href: String, |
| | | rel: { |
| | | type: String, |
| | | default: 'navigate', |
| | | }, |
| | | }, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | methods: { |
| | | handleGoTo() { |
| | | if (!this.href) { |
| | | return; |
| | | } |
| | | if (this.rel === 'navigate') { |
| | | if (this.href === 'back') { |
| | | Taro.navigateBack(); |
| | | } else { |
| | | Taro.navigateTo({ url: this.href }); |
| | | } |
| | | } else if (this.rel === 'redirect') { |
| | | Taro.redirectTo({ url: this.href }); |
| | | } |
| | | }, |
| | | }, |
| | | mounted() {}, |
| | | }; |
| | | </script> |
New file |
| | |
| | | /** |
| | | * CAnchor |
| | | * @author Tevin |
| | | */ |
| | | |
| | | import CAnchor from '@components/layout/anchor/CAnchor.vue'; |
| | | |
| | | export { |
| | | CAnchor, |
| | | } |