12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- Component({
- properties: {
- type: {
- type: String,
- value: ''
- },
- NavigationOrNot: {
- type: Boolean,
- value: false
- }
- },
- data: {
- gaodeType: 'car'
- },
- lifetimes: {
- attached: function() {
- // 在组件实例进入页面节点树时执行
- },
- ready: function() {
- // 在组件布局完成后执行
- this.initialize()
- },
- detached: function() {
- // 在组件实例被从页面节点树移除时执行
- }
- },
- watch: {
- 'properties.NavigationOrNot'(val) {
- console.log('type变化', val)
- }
- },
- methods: {
- initialize: function() {
- // 自定义的初始化方法
- console.log('initialize', this.properties)
- this.setData({
- gaodeType: this.properties.type
- })
- // 例如设置一些初始状态
- },
- setType: function(type) {
- this.setData({
- gaodeType: type
- })
- this.triggerEvent('changeType', {
- gaode_type: type
- });
- },
- goToCar: function() {
- // 处理驾车逻辑
- console.log('驾车')
- this.setType('car')
- },
- goToWalk: function() {
- // 处理步行逻辑
- console.log('步行')
- this.setType('walk')
- },
- goToBus: function() {
- // 处理公交逻辑
- console.log('公交')
- this.setType('bus')
- },
- goToRide: function() {
- // 处理骑行逻辑
- console.log('骑行')
- this.setType('riding')
- }
- }
- })
|