过了一会儿,我明白了:
在functions.php
我添加了一行:
wp_localize_script(\'vue_wordpress.js\',\'sharedData\',array(
\'contactForm\' => do_shortcode(\'[contact-form-7 id="5" title="Formulário de contacto 1"]\')
)
对于我已经存在的功能:
function vue_wordpress_scripts()
{
// Styles
wp_enqueue_style( \'style.css\', get_template_directory_uri() . \'/style.css\' );
// wp_enqueue_style(\'vue_wordpress.css\', get_template_directory_uri() . \'/dist/vue-wordpress.css\');
// wp_enqueue_style(\'global\',get_template_directory() . \'/styles/menu.css\' ); //copiar este código para adicionar mais styles.
// Scripts
// Enable For Production - Disable for Development
// wp_enqueue_script(\'vue_wordpress.js\', get_template_directory_uri() . \'/dist/vue-wordpress.js\', array(), null, true);
// Enable For Development - Remove for Production
wp_enqueue_script( \'vue_wordpress.js\', \'http://localhost:8080/vue-wordpress.js\', array(), false, true );
}
我调用了组件中的短代码。这个错误是我的。