Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 高级自定义字段,设置html5画布文本_Php_Wordpress_Canvas_Html5 Canvas_Advanced Custom Fields - Fatal编程技术网

Php 高级自定义字段,设置html5画布文本

Php 高级自定义字段,设置html5画布文本,php,wordpress,canvas,html5-canvas,advanced-custom-fields,Php,Wordpress,Canvas,Html5 Canvas,Advanced Custom Fields,如果有人能给我提供任何参考或链接,我将不胜感激。我知道我可以用context.fillText Hello World设置画布文本;当只是做直接的画布 我的问题是如何使用高级自定义字段acf field to作为我的文本变量,以便客户端可以自行设置/更改文本 如果我有: <?php the_field('canvas_text'); ?> 如何将其设置为“fillText” 我是否可以使用ACF字段作为变量,然后在画布js中使用它?用于在WordPress中将变量从php传递到ja

如果有人能给我提供任何参考或链接,我将不胜感激。我知道我可以用context.fillText Hello World设置画布文本;当只是做直接的画布

我的问题是如何使用高级自定义字段acf field to作为我的文本变量,以便客户端可以自行设置/更改文本

如果我有:

<?php the_field('canvas_text'); ?>
如何将其设置为“fillText”

我是否可以使用ACF字段作为变量,然后在画布js中使用它?

用于在WordPress中将变量从php传递到javascript,如下所示:

wp_localize_script( 'canvas_js', 'canvas_js_localization', array(
    'canvas_text' => get_field( 'canvas_text' )
) );
context.fillText (canvas_js_localization.canvas_text)
然后在js中使用它,如下所示:

wp_localize_script( 'canvas_js', 'canvas_js_localization', array(
    'canvas_text' => get_field( 'canvas_text' )
) );
context.fillText (canvas_js_localization.canvas_text)
当然,您必须编辑句柄和名称以适合您的场景