我正在将PrimeVue Splitter与 Vue3 和组合 API 结合使用。我想让每个面板的大小动态化,所以当我单击按钮时,它们会返回到原始大小。
这就是我到目前为止所拥有的
<button @click="fixPanels()" >fix</button>
<Splitter style="height: 100%" class="mb-3">
<SplitterPanel :size=smallPanelSize >
Panel 1
</SplitterPanel>
<SplitterPanel :size=bigPanelSize >
Panel 2
</SplitterPanel>
</Splitter>
export default {
setup(){
let smallPanelSize = ref(30)
let bigPanelSize = ref(70)
const fixPanels = ()=>{
message.value = 30;
bigPanelSize.value = 70
}
return{smallPanelSize, bigPanelSize, fixPanels}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以自由调整面板的大小,但是当fixPanels单击 时,它们不会返回到原始大小。我想我必须以某种方式使用双向绑定,或者v-model但我不知道如何使用,这里没有输入。如果这是不可能的,您能否建议一个类似的可调整大小的面板组件,面板尺寸是动态控制的?
谢谢
我使用基于ws 的node.js、express 和express- ws
Express-ws 允许为 websockets 创建类似 express 的端点。
我正在寻找一种基于令牌在 websocket 连接中对用户进行身份验证的解决方案。由于我的 ws 服务器是基于 HTTP 的
const wsHttpServer = http.createServer();
wsHttpServer.listen(5001);
const expressWs = require('express-ws')(app , wsHttpServer);
Run Code Online (Sandbox Code Playgroud)
并且由于 ws 连接基于升级为 ws 的 HTTP 连接,为什么我不能像其他任何连接一样在快速路由检查的 ws 中传递令牌?我的逻辑是,发送令牌,检查它,如果没问题,继续升级到 ws 连接。因此,我可以重用 HTTP 连接中的令牌中间件解决方案。
在节点
我的 ws 服务器
const wsHttpServer = http.createServer();
wsHttpServer.listen(5001);
const expressWs = require('express-ws')(app , wsHttpServer);
//set the route
app.use('/ws', require('./routes/wsroute'));
Run Code Online (Sandbox Code Playgroud)
在该路线中,我想使用token.validate()中间件 - 在 HTTP 连接中,检查 Authorization 标头
router.ws('/user/:name/:id', token.validate(), (ws, req) => {
console.log('ws …Run Code Online (Sandbox Code Playgroud) 我使用node.js v8.11.1并表达4.16.3。
说我有以下路线
app.get('/:id', function(req, res){
Run Code Online (Sandbox Code Playgroud)
我想做类似的事情
if(req.params.id) then query1
else //no id param in the url
query2
Run Code Online (Sandbox Code Playgroud)
因此,我可以前往http://localhost:3000/或到达http://localhost:3000/504,路线将做出相应的响应。
但是当我去http://localhost:3000/我只是得到Cannot GET /
如何修复路线?
谢谢
我正在使用 vue 2.6.14 和composition-api 1.3.3 包来使用composition api。我有
我的 main.js 喜欢
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
import App from './App.vue'
import router from './router'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App)
}).$mount('#app')
Run Code Online (Sandbox Code Playgroud)
我尝试开一家商店
我有一个src folder / store folder / index.js
并在里面index.js
import { reactive } from '@vue/composition-api'
const state = reactive({
counter : 0
})
export default{ state }
Run Code Online (Sandbox Code Playgroud)
在里面App.vue我尝试导入 store 来使用它
<script>
import store from '@/store'
</script>
Run Code Online (Sandbox Code Playgroud)
我收到错误 …