我正在尝试动态更改语言环境以更改i18n语言。我有两个文件,一个具有英语值,另一个具有法国值。
我现在尝试的是这样的:
ngOnInit() {
const localeName = localStorage.getItem('locale') || 'fr';
import(`@angular/common/locales/${localeName}.js`).then(locale => {
registerLocaleData(locale.default);
});
}
Run Code Online (Sandbox Code Playgroud)
但是它给了我以下错误:
error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
Run Code Online (Sandbox Code Playgroud)
关于如何动态地从英语切换到法语的任何想法?:/
<div class="dropup">
<button class="btn btn-primary btn-raised dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectList.selectedListItem}}
<div class="ripple-container"></div>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" ng-repeat="list in roleList" href="#" ng-value="list.role" name="{{list.role}}" ng-click="update(list.role, list._id)" id="{{list.role}}" ng-model="selectList" name="selectedList">{{list.role}}</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我在dropup-menu上使用CSS作为 - >
overflow: scroll;
max-height: 200px;
Run Code Online (Sandbox Code Playgroud)
但它对我不起作用. 还有其他方法吗?
将此Css添加到下拉菜单 - >后更新
overflow: scroll;
max-height: 200px !important;
Run Code Online (Sandbox Code Playgroud)
我的下拉菜单现在看起来没有可滚动 - >
我正在使用 Strapi 创建一个新应用程序,并尝试将它与我的 MongoDB 连接起来,该 MongoDB 托管在 Digital Ocean 上,但不幸的是 Strapi 无法从现有的 MongoDB 获取集合。在这里,我提到了我为实现 Strapi 与现有 MongoDB 连接所遵循的完整步骤:
我已经按照本指南逐步创建了一个 Strapi 应用程序: Quick_Start_Strapi
虽然,我需要连接到我现有的托管在 Digital Ocean 上的 MongoDB。因此,根据 Strapi 文档,我仅在创建 Strapi 应用程序时提到了现有数据库的所有凭据(主机、端口、用户名、密码)。
最后,当应用程序创建成功时,我将当前目录切换到项目目录并运行命令:
$ strapi start
Run Code Online (Sandbox Code Playgroud)我在终端中没有遇到任何错误,因此,这意味着
连接成功
然后,我通过 Strapi 注册面板注册了自己。
我想在电子桌面应用程序中实现通知的粘性行为,直到用户单击通知本身。
我正在使用node-notifier来实现此文档,并使用ngx-electron使用 ElectronService 在角度组件文件中导入 main.js 文件。
这是我的main.js文件:
const notifier = require('node-notifier')
exports.notifier = (msg) => {
notifier.notify({
title: 'Notify Me',
message: msg,
wait: true,
timeout: 1500000,
sound: true,
icon: './assets/images/logo.png'
});
Run Code Online (Sandbox Code Playgroud)
app.component.ts :
import {ElectronService} from 'ngx-electron';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
public main_js : any;
constructor(private _electronService: ElectronService ) {
this.main_js = this._electronService.remote.require("./main.js");
this.getTasks();
}
getTasks() {
var message = 'New Task …Run Code Online (Sandbox Code Playgroud) 我在server.ts 中添加了“domino” ,甚至将webpack.server.config.js更新为:
module: {
rules: [
{ test: /\.(ts|js)$/, loader: 'regexp-replace-loader', options: { match: { pattern: '\\[(Mouse|Keyboard)Event\\]', flags: 'g' }, replaceWith: '[]', } },
{ test: /\.ts$/, loader: 'ts-loader' },
]
}
Run Code Online (Sandbox Code Playgroud)
但仍然收到相同的错误:“ReferenceError - KeyboardEvent 未定义”。
我在终端中运行这些命令
$npm 运行构建:ssr
$npm 运行服务:ssr
在package.json 中定义的命令为:
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --prod && ng run angular.io-example:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
Run Code Online (Sandbox Code Playgroud)
有没有人有想法,如何摆脱这个错误?