Reputation: 797
I wanted to change v-file-input icon and place the icon behind. So I used "append-outer-icon" to change icon and place, but If I click the icon nothing happen. I waned to click the "append-outer-icon" and open folder like click the prepend-icon. My sample code is below.
<template>
<v-file-input
prepend-icon=""
append-outer-icon="mdi-folder-open"
></v-file-input>
</template>
Could anyone advise me?
Upvotes: 1
Views: 3012
Reputation: 63059
You could do this with pure CSS. Use prepend-icon
only, along with:
.v-file-input {
flex-direction: row-reverse;
}
Demo:
new Vue({
vuetify: new Vuetify(),
el: "#app"
})
.v-file-input {
flex-direction: row-reverse;
}
<div id="app">
<br /><br />
<v-app id="inspire">
<v-file-input prepend-icon="mdi-folder-open"
></v-file-input>
</v-app>
</div>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
Upvotes: 3
Reputation: 1
Add a ref to the file input and trigger it using click:append-outer
:
<v-file-input
prepend-icon=""
append-outer-icon="mdi-folder-open"
ref="file"
@click:append-outer="this.$refs.file.$el.querySelector('input').click()"
></v-file-input>
var app = new Vue({
el: '#app',
vuetify: new Vuetify(),
methods:{
open(){
this.$refs.file.$el.querySelector('input').click()
}
}
})
#app{
width:200px;
padding:16px
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app">
<v-file-input prepend-icon="" append-outer-icon="mdi-folder-open" ref="file" @click:append-outer="open"></v-file-input>
</div>
Upvotes: 1