在WordPress页面中使用Vue.js
我在Vue.js中使用Recaptcha实现了一个简单的联系人表单,请参见和 在WordPress页面上添加此表单的正确方法是什么?我没有使用WordPress,因此不清楚在哪里包含脚本以及在哪里放置HTML和PHP。开发一个插件可能太复杂了,有没有可能用几行代码将联系人表单添加到WordPress页面?带有webpack的解决方案:在WordPress页面中使用Vue.js,wordpress,vue.js,Wordpress,Vue.js,我在Vue.js中使用Recaptcha实现了一个简单的联系人表单,请参见和 在WordPress页面上添加此表单的正确方法是什么?我没有使用WordPress,因此不清楚在哪里包含脚本以及在哪里放置HTML和PHP。开发一个插件可能太复杂了,有没有可能用几行代码将联系人表单添加到WordPress页面?带有webpack的解决方案: 创建要包含的vue组件 创建一些index.js或index.ts文件,您可以将其包含在网页包条目中 通过一些钩子在wordpress中添加组件。e、 g添加菜单
add_action( 'admin_menu',array($this, 'register_form_menu_page'));
function register_form_menu_page(){
add_menu_page(
__( 'captcha form', 'theme' ),
__( 'captcha form', 'theme' ),
'edit_posts',
'captchaform',
array($this, 'init_menu_form'),
'dashicons-schedule',
6
);
}
函数初始化菜单表单(){?>
import Vue from 'vue';
import CaptchaForm from "./components/CaptchaForm.vue";
Vue.component('CaptchaForm', CaptchaForm);
var apps = document.getElementsByClassName('app-vue');
for (let i = 0; i < apps.length; i++) {
let element = apps[i];
let id = 'app-vue-' + i;
element.setAttribute('id', id);
new Vue({
el: '#' + id,
});
}
export default apps;