the easiest way is for you to set
in the component.
props:{
time: {
type: Number,
default: 1800
}
}
it is best to set a global variable. Then make a
data.js
export const TOAST_TIME = 1800
import {TOAST_TIME} from '........./data'
props:{
time: {
type: Number,
default: TOAST_TIME
}
}
then you can change it if it is not 1800 special when you pass it in
1. Create a js: of configuration variables
export const TIME = 1800
2. Import this file variable in the required vue file
import {TIME} from './config.js'
in main.js
, write window.TOAST_TIME = 1800
also use window.TOAST_TIME directly to OK
simple and rude
Hey, hey
Don't be misled by me, landlord
the elegant implementation is definitely to package the toash and make it the components, of vue, so that you can write once in this component, introduce the component where you want to use it, and make some parameters into props, that can be customized in every place where the component is called. Wouldn't it be nice
you can use layer.msg ()
< toast
v-model="msg"
type="text"
:time="time"
position="top"
text="">
< / toast >
as a child component, the time when the props receives the time parent component passed by the parent component can introduce a global variable, which can be defined in main.js window.TOAST_TIME = 1800