我不确定这里是不是遗漏了什么,但是当我console.log我的attributes时,我得到了一个空对象。它不应该显示我所有属性的默认数据吗。我在这里做错了什么。
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { useEffect } from '@wordpress/blocks';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import GoogleMap from './GoogleMap.js';
import { Component } from '@wordpress/element';
import axios from 'axios';
registerBlockType( 'splash-blocks/google-maps', {
title: __('Google maps locations', 'google-maps'),
icon: 'megaphone',
category: 'common',
keyword: [
__( 'Display Google maps locations' ),
],
atrributes: {
markers: {
type: 'array',
default: [{
lat: 37.79406,
lng: -122.4002,
}],
},
icon: {
},
address: {
type: 'string',
default: 'xxxxxxxxx',
},
api_key: {
type: 'string',
default: 'xxxxxxxxx',
}
},
edit({ attributes, setAttributes }) {
console.log(attributes)
//Console shows empty object
return (
<div id='google-map'>
</div>
)
},
save: null,
})发布于 2021-04-30 18:37:41
你的街区没有attributes。然而,它确实有atrributes。
将atrributes改为attributes,事情应该更有意义。
https://wordpress.stackexchange.com/questions/387475
复制相似问题