小编Gur*_*ofu的帖子

Vue:.vue模板中未识别哈巴狗语言

从Vue 文档中

处理模板有些不同,因为大多数Webpack模板加载器(例如pug-loader)都返回模板函数而不是已编译的HTML字符串。除了使用pug-loader,我们还可以安装原始的pug。

TestComponent.vue

<template lang="pug">
  div
    h2 {{ message }}
</template>

<script>
  export default {
    data () {
      return {
        message: 'Done!!! Done...'
      }
    }
  }
</script>
Run Code Online (Sandbox Code Playgroud)

main.js

import Vue from 'vue'
import TestComponent from './../components/TestComponent/TestComponent.vue'

new Vue({
  el: '#app',
  render: h => h(TestComponent)
});
Run Code Online (Sandbox Code Playgroud)

错误:

NonErrorEmittedError: (Emitted value instead of an instance of Error) 
  Error compiling template:

  div
    h2 {{ message }}

  - Component template requires a root element, rather than just text.
Run Code Online (Sandbox Code Playgroud)

使用的依赖项版本:

  • “ …

javascript webpack vue.js vuejs2

6
推荐指数
1
解决办法
2522
查看次数

Webpack Pug/HTML 加载器在生产模式下将大写字母转换为小写字母

我正在使用 vue 单文件组件,并将标记和逻辑分别分离到.pug文件中.ts。如果您对我不统一的原因感兴趣,请参阅评论部分。

问题

import template from "@UI_Framework/Components/Controls/InputFields/InputField.vue.pug";
import { Component, Vue } from "vue-property-decorator";

console.log(template);

@Component({
  template,
  components: {
    CompoundControlBase
  }
})
export default class InputField extends Vue {
    // ...
}
Run Code Online (Sandbox Code Playgroud)

在开发构建模式下导出的模板是正确的(为了可读性我对其进行了美化):

import template from "@UI_Framework/Components/Controls/InputFields/InputField.vue.pug";
import { Component, Vue } from "vue-property-decorator";

console.log(template);

@Component({
  template,
  components: {
    CompoundControlBase
  }
})
export default class InputField extends Vue {
    // ...
}
Run Code Online (Sandbox Code Playgroud)

在生产模式下,我的标记已小写。所以,console.log(template)输出:

<CompoundControlBase 
  :required="required" 
  :displayInputIsRequiredBadge="displayInputIsRequiredBadge"
    <TextareaAutosize 
      v-if="multiline" 
      :value="value" 
    /><TextareaAutosize>
</CompoundControlBase> …
Run Code Online (Sandbox Code Playgroud)

html webpack vuejs2 webpack-loader pug-loader

6
推荐指数
1
解决办法
956
查看次数

Vue2中div或其他非按钮上的Enter键触发点击事件

如果元素不是按钮/输入/链接tabindex="0",仅通过关注元素然后按下键来触发单击事件是不够的。Enter还需要什么?

<!--not working, even if the element has focus-->
<div tabindex=0>Trigger click event on me by Enter key!<div>
Run Code Online (Sandbox Code Playgroud)

keyboard focus vue.js

6
推荐指数
1
解决办法
2906
查看次数

我应该在“package.json”的“dependencies”字段中复制“peerDependencies”吗?

为了实验,我下载了@typescript-eslint/eslint-plugin的源代码。这个包有两个对等依赖项:

{
  "peerDependencies": {
    "@typescript-eslint/parser": "^4.0.0",
    "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"
  },
  "dependencies": {
    "@typescript-eslint/experimental-utils": "4.11.1",
    "@typescript-eslint/scope-manager": "4.11.1",
    "debug": "^4.1.1",
    "functional-red-black-tree": "^1.0.1",
    "regexpp": "^3.0.0",
    "semver": "^7.3.2",
    "tsutils": "^3.17.1"
  },
}
Run Code Online (Sandbox Code Playgroud)

如果我npm list在安装所有依赖项后运行,我会得到:

npm ERR! peer dep missing: eslint@^5.0.0 || ^6.0.0 || ^7.0.0, required by @typescript-eslint/eslint-plugin@4.11.1
npm ERR! peer dep missing: eslint@*, required by @typescript-eslint/experimental-utils@4.11.1
Run Code Online (Sandbox Code Playgroud)

这是否意味着npm想要:

npm ERR! peer dep missing: eslint@^5.0.0 || ^6.0.0 || ^7.0.0, required by @typescript-eslint/eslint-plugin@4.11.1
npm ERR! peer dep missing: …
Run Code Online (Sandbox Code Playgroud)

npm package.json

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

如果我们想将包发布到 npm,GitHub 存储库的 markdown 文件内的链接中的完整绝对路径是否不可避免?

假设我们的 GitHub 存储库包含以下 2 个 Markdown 文件:

  • 自述文件.md
  • 文档/SampleDocumentationPage.md

README.md中,我们可以通过相对路径或缩短的绝对路径引用SampleDocumentationPage :

See [sample documentation page](Documentation/SampleDocumentationPage.md)
Run Code Online (Sandbox Code Playgroud)

如果我们将包发布到 NPM,README.md将显示在包的主页上,其 URL 如下。

https://www.npmjs.com/package/$SCOPE_NAME$/$PACKAGE_ID$
Run Code Online (Sandbox Code Playgroud)

README.md中的SampleDocumentationPage.md链接是否有效?我想不是,因为SampleDocumentationPage.md的正确绝对路径是

https://github.com/$USER_NAME$/$REPOSITORY_NAME$/blob/master/Documentation/SampleDocumentationPage.md
Run Code Online (Sandbox Code Playgroud)

而相对于npm,SampleDocumentationPage.md的计算 URL为

https://www.npmjs.com/package/$SCOPE_NAME$/$PACKAGE_ID$/Documentation/SampleDocumentationPage.md
Run Code Online (Sandbox Code Playgroud)

除了仅使用绝对路径之外,还有什么可以做的吗?Markdown 中的绝对路径可能很长,如下所示:

<dl>

  <dt><a href="https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions/blob/master/CoreLibrary/Package/Documentation/Arrays/getArrayElementSatisfiesThePredicateIfSuchElementIsExactlyOne/getArrayElementSatisfiesThePredicateIfSuchElementIsExactlyOne.md">getArrayElementSatisfiesThePredicateIfSuchElementIsExactlyOne</a></dt>
  <dd>Returns the element of specified array matching with the predicate if such element is exactly one, otherwise error will be thrown or null will be returned (depending on dedicated option's value).</dd>

  <dt><a href="https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions/blob/master/CoreLibrary/Package/Documentation/Arrays/getLastElementOfNonEmptyArray/getLastElementOfNonEmptyArray.md">getLastElementOfNonEmptyArray</a></dt>
  <dd>Returns the last element …
Run Code Online (Sandbox Code Playgroud)

markdown github npm

6
推荐指数
1
解决办法
786
查看次数

Laravel 5.5:无法通过谷歌发送电子邮件(SSL 操作失败)

.env在类似问题的答案中看到了以下设置:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=somePassword1234
MAIL_ENCRYPTION=tls
Run Code Online (Sandbox Code Playgroud)

但是,没有任何效果。使用tls加密,我出错了

stream_socket_enable_crypto(): SSL operation failed with code 1. 
OpenSSL Error messages: error:14090086:SSL routines:
ssl3_get_server_certificate:certificate verify failed
Run Code Online (Sandbox Code Playgroud)

使用ssl加密,我收到错误:

Swift_TransportException
Expected response code 220 but got code "", with message ""
Run Code Online (Sandbox Code Playgroud)

php laravel

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

Laravel:定义与公共文件夹子目录相同的路由

我在admin文件夹中有子public文件夹,但我想在mywebsite.loc/admin. 当前,如果输入mywebsite.loc/admin,它将是下一个响应:

在此处输入图片说明

但是我有路由定义admin

Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function(){

    Route::get('/', [
        'as' => 'AdminTop',
        'uses' => //Admin\AdminController@renderTopPage'
        function(){ 
            dd('ok');
        }
    ]);       
});
Run Code Online (Sandbox Code Playgroud)

我怎样才能让它工作?

php laravel

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

防止flex PARENT增长而不溢出:hidden

关于如何防止 Flex Child 增长的信息太多,但很难找到如何防止 Flex PARENT 增长(因为孩子)。

考虑下面的布局:

  • 外部元素的高度和宽度是固定的(适用于本机应用程序)
  • 页眉和页脚既不增长也不缩小。此外,页脚始终位于底部。
  • 主要内容(页眉和页脚之间)占用所有可用空间。
  • 主要内容不滚动。
    • 但内部元素可以滚动。例如 部分标题下方的滚动视图:

在此输入图像描述

初步解决方案:

.layout {
  display: flex;
  flex-direction: column;
  width: 640px;
  height: 300px;
  background: rgba(220, 20, 60, 0.2);
}

.header {
  flex: 0 0 auto;
  padding: 4px 8px;
  background: rgba(220, 20, 60, 0.2);
}

.content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 4px 8px;
  background: rgba(255, 69, 0, 0.2);
  overflow-y: hidden;
}

.title {
  flex: 0 0 auto;
  background: rgba(255, 255, 0, 0.2);
}

.splitView …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

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

ESLint:防止非标准文件扩展名被检查

我的.estintrc.yaml

parser: "@typescript-eslint/parser"
parserOptions:
  sourceType: module
  project: tsconfig.json
  tsconfigRootDir: ./

env:
  es6: true
  browser: true
  node: true
  mocha: true

plugins:
  - "@typescript-eslint"
Run Code Online (Sandbox Code Playgroud)

有了它,我有很多错误,例如:

D:\*****\project\package.json
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: package.json.
The extension for the file (.json) is non-standard. You should add "parserOptions.extraFileExtensions" to your config
Run Code Online (Sandbox Code Playgroud)

我没有要求检查.json文件。我想要.ts.vue只是文件会被检查。我错过了哪个设置?

javascript typescript eslint

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

如何通过原生 TypeScript 实现延迟加载的依赖注入?

框架开发人员喜欢通过实现依赖注入概念来吹嘘。下面的实现是本机的、简单的且类型安全的。

// All below gateways and services are the abstractions
type ApplicationDependencies = Readonly<{
  gateways: Readonly<{
    category: CategoryGateway;
    product: ProductGateway;
  }>;
  services: Readonly<{
    authentication: AuthenticationService;
  }>;
}>;


export default abstract class DependenciesInjector {

  private static dependencies: ApplicationDependencies | null = null;

  public static setDependencies(dependencies: ApplicationDependencies): void {
    DependenciesInjector.dependencies = dependencies;
  }

  private static getDependencies(): ApplicationDependencies {

    if (DependenciesInjector.dependencies === null) {
      throw new Error("The DependenciesInjector has not been initialized");
    }


    return DependenciesInjector.dependencies;
  }


  public static get gateways(): ApplicationDependencies["gateways"] …
Run Code Online (Sandbox Code Playgroud)

dependency-injection lazy-loading typescript

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