我正在尝试使用axios发布我的表单,但我无法使用expressjs将数据提供给我的后端
这就是我在做的事情:
<template>
<form class="" method="post" @submit.prevent="postNow">
<input type="text" name="" value="" v-model="name">
<button type="submit" name="button">Submit</button>
</form>
</template>
export default {
name: 'formPost',
data() {
return {
name: '',
show: false,
};
},
methods: {
postNow() {
axios.post('http://localhost:3030/api/new/post', {
headers: {
'Content-type': 'application/x-www-form-urlencoded',
},
body: this.name,
});
},
components: {
Headers,
Footers,
},
};
Run Code Online (Sandbox Code Playgroud)
后端文件:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
router.post('/new/post', (req, res) => {
res.json(console.log("this is working" + ' ' + req.body.name));
});
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
this is working undefined
Run Code Online (Sandbox Code Playgroud) 我正在构建这个Vue 2应用程序,我一直在阅读一个人应该使用Vuex State管理,一开始我不太了解它的概念,但现在在玩了Vue之后,我可以看到它是一个更大的应用程序.
但我的问题是,有人可以从Dev控制台或任何形式访问存储在store.js中的数据,我的意思是那些我不会渲染到浏览器的数据?
我可以将灵敏数据保存在商店,敏感,我的意思是,用户点击此链接,向此用户发送消息,在此页面上花了这么多时间等...并且平均时间将所有这些数据上传到我的数据库..
Vuex商店是否适合这种工作/工作?
干杯
我无法从我的组件中的一个Vuex模块访问getter,即使我可以在Vue Dev Tools中看到getter.
我的store.js档案:
import Vue from 'vue';
import Vuex from 'vuex';
import subsub from './modules/subsub';
Vue.use(Vuex);
export default new Vuex.Store({
state: { },
actions: { },
mutations: { },
getters: { },
modules: {
subsub,
},
});
Run Code Online (Sandbox Code Playgroud)
我的modules/subsub.js档案:
const state = {
categories: [{
name: 'one',
path: 'two',
...
}, {
name: 'twocat',
path: 'two',
...
}],
};
const actions = { };
const mutations = { };
const getters = {
filterCategories(state) {
return …Run Code Online (Sandbox Code Playgroud) 所以,我创建了这个搜索组件,因为我会多次使用它。
我的搜索组件(子组件)如下所示:
<template>
<div class="input-group main-search">
<input class="input-group-field" type="text" value="" :placeholder="placeholder" :id="searchId">
<div class="input-group-button">
<input type="submit" class="button" value="Search">
</div>
</div>
</template>
<script>
export default {
props: ['placeholder', 'searchId'],
name: 'search',
data() {
return {
};
},
};
</script>
Run Code Online (Sandbox Code Playgroud)
我将它包含在我的父组件(带有类别的搜索页面)中,下面的示例对我有用......但我想让它以某种方式从该组件中返回的数据中获取数据并以某种方式绑定到。
<template>
<search placeholder="placeholder text" id="id number"></search>
<p>some text here </p>
</template>
Run Code Online (Sandbox Code Playgroud)
那么是否有任何形式从返回的数据中传递数据,例如:
data() {
return {
searchProps: [
{
placeholder: 'Watafaka',
searchId: '2',
},
],
Run Code Online (Sandbox Code Playgroud)
期待有人的帮助:)
我在玩 Vue 2,我想让整个 div 可点击。这个 div 有一个链接、图像和文本。
我将路由器链接用于标题和其他链接中的链接,但是当我尝试使用其他内容时,页面会不断刷新。
有人可以帮我解决这个问题吗..
干杯!
我不是CSS专家,但直到现在我还没有看到这样的"问题".
所以,我正在使用Vuetify并为搜索表单添加了一个..
现在该组件正在创建:
<div input-group input-group--prepend-icon input-group--text-field primary--text>
<label for="search"></label>
<div class="input-group__input"></div>
<div class="input-group__details"></div>
<div class="input-group__messages"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我的问题是类.input-group__messages有一个最小高度,我希望它在这种情况下有1px或不显示,但我无法从我的组件中编辑它...有办法去根本风格,但我不想这样做,我想学习或知道什么是我错过的问题.
期待有人的回复