小编cod*_*bot的帖子

使 PrimeVue Splitter 具有动态双向面板尺寸

我正在将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但我不知道如何使用,这里没有输入。如果这是不可能的,您能否建议一个类似的可调整大小的面板组件,面板尺寸是动态控制的?

谢谢

splitter vue.js v-model primevue vuejs3

2
推荐指数
1
解决办法
1209
查看次数

使用中间件和 node.js 表达的 Websockets 令牌认证

我使用基于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)

authentication token websocket node.js express

1
推荐指数
1
解决办法
6547
查看次数

带有或不带有参数的express.js路由

我使用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 /

如何修复路线?

谢谢

routes node.js express

0
推荐指数
2
解决办法
721
查看次数

vue2 和合成 api - 无法导入存储,错误 [vue-composition-api] 在使用任何函数之前必须调用 Vue.use(VueCompositionAPI)

我正在使用 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)

我收到错误 …

state store vue.js vuejs2 vue-composition-api

0
推荐指数
1
解决办法
2540
查看次数