小编Sha*_*hua的帖子

在 nextjs 中使用谷歌字体与 sass、css 和语义 ui 反应

我有一个具有以下配置的 next.config.js 文件:

const withSass = require('@zeit/next-sass');
const withCss = require('@zeit/next-css');

module.exports = withSass(withCss({
  webpack (config) {
    config.module.rules.push({
      test: /\.(png|svg|eot|otf|ttf|woff|woff2)$/,
      use: {
        loader: 'url-loader',
        options: {
          limit: 100000,
          publicPath: './',
          outputPath: 'static/',
          name: '[name].[ext]'
        }
      }
    })

    return config
  }
}));
Run Code Online (Sandbox Code Playgroud)

这很棒,因为它运行我的语义 ui css 文件。

现在我有一个问题。我似乎无法成功导入任何谷歌字​​体网址。我尝试将 ttf 文件下载到我的文件路径中,并尝试使用 @import scss 函数引用它。但是我得到一个 GET http://localhost:3000/fonts/Cabin/Cabin- Regular.ttf net::ERR_ABORTED 404 (Not Found) 错误

这是我试图用谷歌字体做的事情:

@font-face {
  font-family: 'Cabin';
  src: url('/fonts/Cabin/Cabin-Regular.ttf')  format('truetype');
}

$font-size: 100px;
.example {
  font-size: $font-size;
  font-family: 'Cabin', sans-serif;
}
Run Code Online (Sandbox Code Playgroud)

我还下载了相关的 npm …

css sass reactjs next.js

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

仅将角度材料主题应用于特定组件

是否可以将 angular material 内置主题仅应用于特定组件?

我做了:

@import "~@angular/material/prebuilt-themes/indigo-pink.css";
Run Code Online (Sandbox Code Playgroud)

在我的 component.scss 文件之一中,并将其作为 component.ts 文件中的 styleUrl 引用。但是这些样式不适用于我的 angular material paginator。

这是分页器的样子

在此处输入图片说明

如图所示,样式不适用。

这是否与我将它们导入到组件特定的 scss 文件中而不是在 angular.json 中导入的事实有关?

angular-material angular angular6

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

编辑 ngx-datatable 样式问题

我正在遵循 ngx-datatable 的主题设置。

首先,我 npm 安装了 ngx-datatable 10.4.0,因为它与 Angular 4 和早期版本的 rxjs 兼容。

我的问题是表格的样式。

我的模板文件如下所示:

<div>
    <ngx-datatable
        [rows]="rows"
        [columns]="columns"
        [columnMode]="'standard'"
        class="material"
        fixed-header
        [headerHeight]="50"
        [scrollbarV]="true">
    </ngx-datatable>
</div>
Run Code Online (Sandbox Code Playgroud)

我的 scss 文件内部:

@import '~@swimlane/ngx-datatable/release/index.css';
@import '~@swimlane/ngx-datatable/release/themes/material.css';
@import '~@swimlane/ngx-datatable/release/themes/bootstrap.css';
@import '~@swimlane/ngx-datatable/release/assets/icons.css';
Run Code Online (Sandbox Code Playgroud)

我可以确认材质样式在一定程度上有效: 在此输入图像描述

我想在标题下添加边框底部,但无济于事。

如果您查看演示:http://swimlane.github.io/ngx-datatable/#filter

示例表始终有一个底部边框。

如何配置表格以在标题下方插入边框底部?

我的 ngx-datatable 设置有问题吗?

ngx-datatable angular

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

Angular 5 'Content-Type':'multipart/form-data' 被重置为 'application/json'

嗨,我在尝试让 httpClient 补丁请求发送内容类型为“multipart/form-data”的 FormData 时遇到问题。

我已经指定了标题,如图所示:

  private httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'multipart/form-data', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache'
    })
  };
Run Code Online (Sandbox Code Playgroud)

我执行以下操作以保存到 nodejs 服务器:

const formData: FormData = new FormData();
formData.append('materialFile', 'something');
return this.httpClient.patch<any>(this.apiUrl  + loan.id, formData, this.httpOptions);
Run Code Online (Sandbox Code Playgroud)

在我的 Nodejs/Express 服务器上,我执行以下操作:

const Multer  = require('multer');

router.patch('/:id', Multer().fields([{ name: "materialFile", maxCount: 1 }]), (req, res, next) => {
  console.log(req.files['materialFile']);
});
Run Code Online (Sandbox Code Playgroud)

当我检查浏览器上的请求标头时,我看到内容类型是 application/json。

有谁知道为什么?

express multer angular angular-httpclient angular5

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

React Native FlatList KeyboardShouldPersistTaps 不持久

我的处境非常令人沮丧。尝试让键盘消失并检测子行中的 onPress 事件处理程序。

我的代码如下所示:

  _renderRow = (prediction) => {
    return (
      <TouchableOpacity onPress={() => {
        Keyboard.dismiss();
        this.setState({ location: prediction.description });
      }}>
        <View style={styles.listItemContainer}>
          <Text>{prediction.description}</Text>
        </View>
      </TouchableOpacity>
    )
  }

  render() {
    return (
    <View style={styles.wrapper}>
      {/* style={[this.state.predictions.length > 0 ? styles.searchContainerSuggest : styles.searchContainer]} */}
      <View style={styles.searchContainerSuggest}>
        <View style={{paddingLeft: 10, height: 45, display: 'flex', justifyContent: 'center'}}>
          <TextInput
            placeholder="Enter location"
            value={this.state.location}
            onChangeText={location => this.onChangeLocation(location)}
            style={styles.textInput}
          />
        </View>
        {this.state.predictions.length && this.state.location !== '' ?
          <FlatList
            keyboardShouldPersistTaps={'handled'}
            refreshing={!this.state.loaded}
            initialNumToRender={10}
            enableEmptySections={true}
            data={this.state.predictions}
            keyExtractor={(_, index) => index.toString()} …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-flatlist

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

Angular 6:从后端服务器获取File对象后下载文件

我有一个结构为{type:“ Buffer”,data:Array(702549)}的File对象类型,我需要在angular 6中做什么才能在浏览器中下载该文件?

我从此函数得到响应:

  getMarketingProposalById(id: string): Observable<MarketingProposal> {
    return this.httpClient.get<MarketingProposal>(this.apiUrl  + id , this.httpOptions).pipe(map(marketingProposal => {
      if (marketingProposal.materials[0] && marketingProposal.materials[0].file) {
        const blob = new Blob([marketingProposal.materials[0].file.data], { type: 'image/png' });
        console.log(blob);
        // saveAs(blob, 'hello.png');
      }
      const marketingProposalObject = this.assignMarketingProposalObject(marketingProposal);
      this.mapStringToDate(marketingProposalObject);
      return marketingProposalObject;
    }));
  }
Run Code Online (Sandbox Code Playgroud)

marketingProposal.materials [0] .file的格式为{类型:“缓冲区”,数据:数组(702549)}

angular-universal angular angular6

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

使用nodemailer发送模板电子邮件,样式损坏

尝试使用nodemailer发送模板电子邮件并使用把手制作模板。

电子邮件确实已发送,但电子邮件的样式不正确。看起来像这样

在此输入图像描述

我已附上我在车把模板中编写的内容

<!DOCTYPE html>
<html>
    <head>
    <title>Welcome to</title>
    <style>
        @import url('https://fonts.googleapis.com/css?family=Cabin');
        body { margin: 0; padding: 0; left: 0; top: 0; background-color: white; }
        h1 { font-family: 'Cabin'; font-weight: 600; color: rgba(5,45,84,1); margin-left: 2px;}
        p { font-family: 'Cabin'; font-weight: 400; font-size: 11pt; color: rgba(5,45,84,1); margin-left: 2px; }
        h3 {
            margin-top: 50px;
            color: rgba(5,45,84,.25);
            font-family: 'Cabin'; 
            font-weight: 400; 
            font-size: 10pt;
            width: 80vw;
        }
        h2 {
            text-align: center;
            margin-top: 25px;
            margin-bottom: 10px;
            color: rgba(5,45,84,1);
            font-family: 'Cabin'; 
            font-weight: 400; 
            font-size: 10pt;
        } …
Run Code Online (Sandbox Code Playgroud)

html handlebars.js nodemailer express-handlebars

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