0

店頭テーマに切り替えたらリーフレットマップが消えました。どのように見えるかをリンクする

関数.php

    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
        /* wp_enqueue_style( 'bootstrap', 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' ); */
        wp_enqueue_style( 'leaflet.css','http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css');
    }

    function theme_scripts(){

        wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js', array('jquery'), '1.12.2', false); 
        wp_enqueue_script('bootstrap-js', 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', array('jquery'), false);
        wp_enqueue_script('leaflet.js', 'http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js' ,false);
        wp_enqueue_script('main.js', get_template_directory_uri(). '/js/main.js');

    }

    add_action( 'wp_enqueue_scripts', 'theme_scripts' );

Bootstrap は、Web サイトのビューを壊す (サイズが小さくなる) ため、コメントされています。ただし、コメントを付けないと、それでもマップは機能しません。

地図ページへのリンクを追加しました。それが適切な方法かどうかはわかりません。

<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri() ; ?>/css/bootstrap.min.css">
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri() ; ?>/js/main.js"></script>
4

2 に答える 2

0

コンソールを調べると役に立ちました。

TypeError: $ は関数ではありません

main.js で次の行を変更します。

$( document ).ready(function() {

jQuery( document ).ready(function($) {
于 2016-06-21T12:18:46.290 に答える