javascript - 如何使用 AngularJS 从自定义 URL 获取字体?

标签 javascript angularjs twitter-bootstrap angular-ui

我关注这个 documentation使用 BootStrap 日期选择器。

这是我的 HTML header :

    <!--jquery & jquery cookie-->
    <script src="/node_modules/jquery/dist/jquery.min.js"></script>
    <script src="/node_modules/jquery-cookie/jquery.cookie.js"></script>

    <!--bootstrap-->
    <script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">

    <!--font-awesome-->
    <link rel="stylesheet" href="/node_modules/font-awesome/css/font-awesome.min.css">

    <!--summernote-->
    <link rel="stylesheet" href="/node_modules/summernote/dist/summernote.css">
    <link rel="stylesheet" href="/node_modules/summernote/dist/summernote-bs3.css">
    <script src="/node_modules/summernote/dist/summernote.min.js"></script>


    <!--angular-->
    <!--Note: for debugging purpose use non-minified angular, need to use angular.min.js for production-->
    <script src="/node_modules/angular/angular.js"></script>
    <!--<script src="/node_modules/angular/angular.min.js"></script>-->
    <script src="/node_modules/angular-resource/angular-resource.min.js"></script>
    <script src="/node_modules/angular-route/angular-route.min.js"></script>
    <script src="/node_modules/angular-sanitize/angular-sanitize.min.js"></script>

    <!--angular-summernote-->
    <script src="/node_modules/angular-summernote/dist/angular-summernote.min.js"></script>


    <!--angular-bootstrap-->
    <script src="/node_modules/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
    <link rel="stylesheet" href="/node_modules/angular-bootstrap/ui-bootstrap-csp.css">

添加选择器时,出现以下错误:
jquery.js:5246 GET http://localhost:8888/public/fonts/bootstrap/glyphicons-halflings-regular.woff2 (anonymous function) @ jquery.js:5246n.fn.extend.domManip @ jquery.js:5414n.fn.extend.after @ jquery.js:5244domInsert @ angular.js:5010$AnimateProvider.$get.enter @ angular.js:5173(anonymous function) @ angular.js:23761publicLinkFn @ angular.js:7408$get.boundTranscludeFn @ angular.js:7553controllersBoundTransclude @ angular.js:8169ngIfWatchAction @ angular.js:23752$get.Scope.$digest @ angular.js:15667$get.Scope.$apply @ angular.js:15935(anonymous function) @ angular.js:23244n.event.dispatch @ jquery.js:4435n.event.add.r.handle @ jquery.js:4121
public/fonts/bootstrap/glyphicons-halflings-regular.woff:1 GET http://localhost:8888/public/fonts/bootstrap/glyphicons-halflings-regular.woff 
public/fonts/bootstrap/glyphicons-halflings-regular.ttf:1 GET http://localhost:8888/public/fonts/bootstrap/glyphicons-halflings-regular.ttf 

我没有 public/fonts/bootstrap文件夹,但我确实有一个到 node_modules/bootstrap 的静态路由器文件夹。

如何在不移动文件夹的情况下使用它?

我的文件夹结构:
/root
    /server
        /blog
    /client
        /blog
    /public
        /script
        /style
        /image
        /blog
    /node_modules
        /angular
        /bootstrap
        /etc

最佳答案

您可能没有复制 Bootstrap 字体。一些第三方库假定字体存在于 /public 下。 .

如果您使用 gulp,这里有一个从 node_modules 复制字体的虚拟任务至public :

gulp.task('copy:font', function() {
    return gulp.src('/node_modules/bootstrap-sass/assets/fonts/**')
        .pipe(gulp.dest('/public/fonts'))
})

关于javascript - 如何使用 AngularJS 从自定义 URL 获取字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31498800/

相关文章:

javascript - 如何使用 chai 测试浮点相等性?

javascript - AngularJS 2 和网络组件、模拟和 polyfill

javascript - Angular : how to keep resetting $timeout on scroll events, 否则让 $timeout 完成

javascript - fullCalendar ListView 无法显示

css - Bootstrap 图标未显示

html - 指定网格中的行数和列数

javascript - 是否可以使用 for 循环编辑多个数组?

javascript - 将其他语言的数字更改为英文数字的正则表达式

asp.net-mvc-4 - 使用 angularjs 和 ASP.NET MVC

javascript - 如何将 csv 转换为数组