File tree Expand file tree Collapse file tree 3 files changed +67
-9
lines changed Expand file tree Collapse file tree 3 files changed +67
-9
lines changed Original file line number Diff line number Diff line change 15
15
Use the UMD build from [ Unpkg] ( https://unpkg.com/vue-input-autowidth ) , available as ` VueInputAutowidth ` in the global scope.
16
16
17
17
``` html
18
- <script src =" /vendor/vue.js" >
19
- < script src= " https://unpkg.com/vue-input-autowidth" >
18
+ <script src =" /vendor/vue.js" / >
19
+ < script src= " https://unpkg.com/vue-input-autowidth" / >
20
20
` ` `
21
+
22
+ ## Usage
23
+
24
+ ### Globally
25
+
26
+ Import and register the directive in your app's entrypoint.
27
+
28
+ ` ` ` js
29
+ import { createApp } from " vue" ;
30
+ import App from " ./App.vue" ;
31
+ import { plugin as VueInputAutowidth } from " vue-input-autowidth" ;
32
+
33
+ createApp (App).use (VueInputAutowidth).mount (" #app" );
34
+ ` ` `
35
+
36
+ ### Per-component
37
+
38
+ ` ` ` js
39
+ < script>
40
+ import { directive as VueInputAutowidth } from " vue-input-autowidth"
41
+
42
+ export default {
43
+ directives: { autowidth: VueInputAutowidth },
44
+ setup () {
45
+ ...
46
+ },
47
+ }
48
+ </script >
49
+ ```
50
+
51
+ ...and in your template:
52
+
53
+ ``` html
54
+ <template >
55
+ <input type =" text" placeholder =" First Name" v-model =" msg" v-autowidth />
56
+ </template >
57
+ ```
58
+
59
+ You can also pass some options:
60
+
61
+ ``` html
62
+ <template >
63
+ <input
64
+ type =" text"
65
+ placeholder =" First Name"
66
+ v-model =" msg"
67
+ v-autowidth =" {
68
+ minWidth: '75px',
69
+ maxWidth: '75%',
70
+ comfortZone: '1ch',
71
+ }"
72
+ />
73
+ </template >
74
+ ```
75
+
76
+ ## License
77
+
78
+ MIT © [ Collin Henderson] ( https://github.com/syropian )
Original file line number Diff line number Diff line change 3
3
"version" : " 0.0.0" ,
4
4
"scripts" : {
5
5
"dev" : " vite" ,
6
- "build" : " vue-tsc --noEmit && vite build -c ./vite.demo.config.ts " ,
6
+ "build" : " vue-tsc --noEmit && vite build" ,
7
7
"serve" : " vite preview"
8
8
},
9
9
"dependencies" : {
Original file line number Diff line number Diff line change 59
59
</div >
60
60
</template >
61
61
62
- <script setup lang="ts" >
63
- import { Ref , ref } from " vue" ;
62
+ <script setup>
63
+ import { ref } from " vue" ;
64
64
65
- const msg: Ref < string > = ref (" " );
65
+ const msg = ref (" " );
66
66
67
67
const installCode = ref (` $ npm install vue-input-autowidth@next --save
68
68
# or...
69
69
$ yarn add vue-input-autowidth@next` );
70
70
const addGlobalCode = ref (` import { createApp } from 'vue'
71
71
import App from './App.vue'
72
- import VueInputAutowidth from 'vue-input-autowidth'
72
+ import { plugin as VueInputAutowidth } from 'vue-input-autowidth'
73
73
74
74
createApp(App).use(VueInputAutowidth).mount("#app")
75
75
` );
76
76
const perComponentCode = ` import { directive as VueInputAutowidth } from 'vue-input-autowidth'
77
77
78
- export default defineComponent( {
78
+ export default {
79
79
directives: { autowidth: VueInputAutowidth },
80
80
setup() {
81
81
...
82
82
},
83
- }) ` ;
83
+ }` ;
84
84
const useDirectiveCode = ` <input
85
85
type="text"
86
86
placeholder="Watch me change size with my content!"
You can’t perform that action at this time.
0 commit comments