小编rdh*_*aut的帖子

9
推荐指数
1
解决办法
9713
查看次数

困惑:如何使用 es6 浏览器模块和 Typescript(不带模块捆绑器)

我想用 es6 模块组织我的打字稿代码,并通过脚本 type="module" 直接在浏览器中加载它们。我已经检查了支持(https://caniuse.com/#feat=es6-module)并且它可以工作。我使用的是 chrome 66 版本。

我尝试过但没有成功(参见下面的代码),而且我对使用的正确策略感到困惑。

解决方案1:在app.ts文件中,我应该导入外部模块,但是如何加载正确的js文件?

解决方案 2:在 app.ts 文件中,我应该直接导入 .js 代码,但如何引用 .d.ts 文件来进行类型签入?

任何帮助将不胜感激。

=================================================== =====================

这是我尝试过的代码

我的index.html 文件

<!-- index.html -->
<!DOCTYPE html>
<html>

<head>
  <title>Welcome</title>
</head>

<body>
  <div id="app">
    <img src="https://vuejs.org/images/logo.png" alt="Vue logo">
    <h1>{{ msg }}</h1>
  </div>

  <script type="module" src="app.js"></script>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

我的 app.ts 文件

//Solution 1
// import Vue from "vue"; // Uncaught TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", …
Run Code Online (Sandbox Code Playgroud)

typescript es6-modules vuejs2

5
推荐指数
1
解决办法
2174
查看次数

通过RequestCultureProviders处理路径(URL)中的文化

我想创建一个合适的requestCultureProviders来处理来自AspNetCore WebApp中路由的文化,并使用以下路由模板:http // url.domain/{culture}/{controller}/{action}

示例:

我发布了我的第一个脏/草案解决方案.

c# url localization asp.net-core

4
推荐指数
1
解决办法
3103
查看次数

如何在我的 vuejs 应用程序中使用从外部 cdn 加载的 bing 地图?

如何在 vue js 应用程序中使用 bing maps api 来显示地图?

注意:我使用 Bing 地图 V8 和 vuejs 2.5.17。

这是我的模板

<template>
   <div id="map"></div>
</template>
Run Code Online (Sandbox Code Playgroud)

这是我的风格

<style lang="scss" scoped>
   #map {
      height: 300px;
      width: 500px;
   }
</style>
Run Code Online (Sandbox Code Playgroud)

这是我的脚本部分(我使用基于类的对象组件)

mounted() {
   let mapElement: HTMLElement = <HTMLElement>document.getElementById("map")
   var map = new Microsoft.Maps.Map(mapElement, {
     credentials: [API_KEY]
   });
}
Run Code Online (Sandbox Code Playgroud)

这就是我在我的应用程序中包含来自 cdn 的外部脚本的方式。经过一番研究,我发现并尝试了以下 2 个选项

选项 1:我已将脚本直接包含在我的 index.html 文件中:

<!-- index.html -->
...
<head>
   ...
   <script src="https://www.bing.com/api/maps/mapcontrol?key=[API_KEY]" async defer></script>
</head>
Run Code Online (Sandbox Code Playgroud)

选项 2:我以编程方式从我的组件中的安装方法中注入文档中的脚本,如下所示

mounted() { 
   // Add programmaticaly the external …
Run Code Online (Sandbox Code Playgroud)

cdn bing-maps typescript vuejs2

3
推荐指数
1
解决办法
1529
查看次数

浏览器中的 Asp.net Core 空 .scss 文件

我在Visual Studio 2015下开发了一个Asp.net Core MVC WebApplication 。我正在我的 Web 应用程序中处理Sass 文件。为了让前端开发人员的生活更轻松,我希望将 .css 文件映射到浏览器 (Chrome) 中的 .scss 文件。

我已经添加的.css文件和.css.map文件和.scss下源文件的wwwroot文件夹中。(可以肯定的是,它是公共文件夹)。

所以我的结构是

项目名
  万维网
    css
    蠢货

但是当我在浏览器中打开文件时,它总是空的。

我已经在我的 Startup.cs 文件中添加了app.UseDirectoryBrowser();app.UseStaticFiles();以确保它可以工作。

我可以看到我的文件,但是当我点击它时,......没有任何反应(白页)。

我错过了什么?

c# debugging google-chrome sass asp.net-core-mvc

2
推荐指数
1
解决办法
1339
查看次数

如何在视图中获取 Asp.net Core Identity 用户

在Asp.net core mvc项目中,如何在View中获取当前的IdentityUser信息?

asp.net-core-identity asp.net-core-mvc-2.0

2
推荐指数
2
解决办法
5331
查看次数

Asp.net Core 允许使用 CORS 自定义标头(客户端使用 axios)

我在客户端和 Asp.net Core Web Api 服务器端有一个应用程序(在 Vuejs 中)+ axios。我添加了一个 jwt 令牌身份验证。我已将服务器配置为在令牌过期时添加自定义标头。(我在响应中有“Token-Expired”标头)。

来自 axios 拦截器的 error.response.headers 对象中不存在标头“token-expired”......(注意:这是令人沮丧的,因为标头存在于 Postman 上但不存在于 axios 中)。

编辑:github 上的这个问题似乎与我的情况类似https://github.com/axios/axios/issues/606

cors asp.net-core axios asp.net-core-webapi

2
推荐指数
1
解决办法
1401
查看次数