export const useSize = { ratio:readonly(ratio), setRatio: () => { let w = window.innerWidth; let h = window.innerHeight; let wRatio = w / Width; let hRatio = h / Height; ratio.value = wRatio > hRatio ? hRatio : wRatio } }
时间: 2023-03-14 16:53:58 浏览: 75
我们可以使用以下代码来设置尺寸:export const useSize = {ratio:readonly(ratio),setRatio:()=>{let w = window.innerWidth; let h = window.innerHeight; let wRatio = w / Width; let hRatio = h / Height;ratio.value = wRatio > hRatio ? hRatio : wRatio}}
相关问题
import { ref, readonly } from 'vue' const date = ref(new Date()) setInterval(() => { date.value = new Date(); },1000) export const getDate = { date: readonly(date) }
你好,根据你的描述,我可以推断出你想要创建一个可以定时更新时间的Vue组件。我可以给你一些建议:首先,你可以使用ref方法定义一个Date对象,并使用setInterval方法定时更新该对象,最后,使用readonly方法将日期对象导出,以便其他组件可以使用它。希望这可以帮到你!
export const loginApi = () => request.get('/user/login')怎么添加参数
你可以在 `get` 方法中传递一个对象来添加参数。例如,如果你想要传递一个名为 `username` 的参数,可以这样写:
```
export const loginApi = (username) => request.get('/user/login', { params: { username }})
```
这里使用了 ES6 的对象简写语法 `{ username }`,相当于 `{ username: username }`。如果你想要传递多个参数,可以继续在对象中添加属性,如:
```
export const loginApi = (username, password) => request.get('/user/login', { params: { username, password }})
```
在调用这个函数时,可以像这样传递参数:
```
loginApi('myUsername', 'myPassword')
```