首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >默认属性为空。

默认属性为空。
EN

WordPress Development用户
提问于 2021-04-30 18:23:15
回答 1查看 415关注 0票数 2

我不确定这里是不是遗漏了什么,但是当我console.log我的attributes时,我得到了一个空对象。它不应该显示我所有属性的默认数据吗。我在这里做错了什么。

代码语言:javascript
复制
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,
})
EN

回答 1

WordPress Development用户

回答已采纳

发布于 2021-04-30 18:37:41

你的街区没有attributes。然而,它确实有atrributes

atrributes改为attributes,事情应该更有意义。

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/387475

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档