我可以在完整日历中使用 use 变量来渲染事件数据吗?


Can i use a use variable in Fullcalendar for render events data?

我在WordPress中将Fullcalendar用于我的事件日历插件。我正在使用WordPress wp_localize_script函数,以便我可以将PHP变量用作JavaScript变量。这是我的本地化代码

    // - json items -
    $jsonevents[]= array(
        'title' => $post->post_title,
        'allDay' => false, // $stime,
        'start' => $st,
        'end' => $et,
        'url' => get_post_type_archive_link('event')
        );
    endforeach;
    else :
    endif;
$sawon =  json_encode($jsonevents);
wp_localize_script( 'fullcalendar', 'localized_script',$sawon);

这是我的jquery脚本

$(function() {
    ("#calendar").fullCalendar({
        header :{
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
        events : localized_script
    });
});

我的全日历不显示任何事件,但localized_script在我的浏览器中可用。控制台还显示一个名为"无法加载资源"的错误,我的localized_script value。问题是什么,解决方案是什么?

$jsonevents= array(
        'title' => 'post_title',
        'allDay' => false, // $stime,
        'start' => '2017-01-01',
        'end' => '2017-01-03',
        'url' => 'archive link'
        );
$sawon =  json_encode($jsonevents);
wp_localize_script($this->plugin_name, 'local_script',
    array( 
        'ajax_url' => wp_make_link_relative(admin_url( 'admin-ajax.php' )),
        'ajax_nonce' =>$sawon,
        )
    );

这是浏览器控制台中的本地化脚本结果。