docs(Slider): use composition api

This commit is contained in:
chenjiahan
2020-12-08 20:54:06 +08:00
parent 9a6449ec31
commit 9af0840f36
3 changed files with 73 additions and 57 deletions
+27 -23
View File
@@ -19,18 +19,19 @@ app.use(Slider);
```
```js
import { ref } from 'vue';
import { Toast } from 'vant';
export default {
data() {
setup() {
const value = ref(50);
const onChange = (value) => {
Toast('Current value: ' + value);
};
return {
value: 50,
value,
onChange,
};
},
methods: {
onChange(value) {
Toast('Current value' + value);
},
},
};
```
@@ -44,19 +45,20 @@ Add `range` attribute to open dual thumb mode.
```
```js
import { ref } from 'vue';
import { Toast } from 'vant';
export default {
data() {
setup() {
// value must be an Array
const value = ref([10, 50]);
const onChange = (value) => {
Toast('Current value: ' + value);
};
return {
// value must be an Array
value: [10, 50],
value,
onChange,
};
},
methods: {
onChange(value) {
Toast('current value' + value);
},
},
};
```
@@ -123,19 +125,21 @@ export default {
```
```js
import { ref } from 'vue';
import { Toast } from 'vant';
export default {
data() {
setup() {
const value = ref(50);
const value2 = ref([10, 50]);
const onChange = (value) => {
Toast('Current value: ' + value);
};
return {
value: 50,
value2: [10, 50],
value,
value2,
onChange,
};
},
methods: {
onChange(value) {
Toast('Current value' + value);
},
},
};
```