小编Nan*_*ncy的帖子

正确地惯性重定向到另一个页面?

我试图在点击时重定向到另一个页面,由于某种原因它不起作用。这是我的 vue 上重定向按钮所在的代码。我尝试了两种不同的方法,但都不起作用。

<el-row class="import-btn">
    <a :href="'/imports/teachers'">
        <el-button type="warning">
            Importar
        </el-button>
    </a>
</el-row>
<el-row class="import-btn">
    <el-button type="warning" @click="redirectStudents()">
        Importar
    </el-button>
</el-row>
Run Code Online (Sandbox Code Playgroud)
redirectStudents() {      
  this.$inertia.visit('/imports/students');
},
Run Code Online (Sandbox Code Playgroud)

我有这样的 web.php 路由

Route::resource('imports/students', 'ImportStudentController');
Route::resource('imports/teachers', 'ImportTeacherController');
Run Code Online (Sandbox Code Playgroud)

在两个控制器中,我目前只填充了index()

public function index()
{
   return Inertia::render('Import/Students');
}
Run Code Online (Sandbox Code Playgroud)
public function index()
{
    return Inertia::render('Import/Teachers');
}
Run Code Online (Sandbox Code Playgroud)

在教师和学生的 vue 文件中,我有这些页面的基本布局和标题,因此它们不是空的。

当我单击该<a :href="">按钮时,我会被重定向到该链接,但页面完全空白,当我单击另一个按钮时,它会打开,就像一个窗口一样,里面也是空白的。

解决这个问题的正确方法是什么?

inertiajs laravel vue.js element-ui

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

如何在我的项目上设置惯性,当我尝试加载登录页面时出现错误

我正在尝试设置 Inertia 以在我的 Laravel 项目中使用,但它给了我错误?我的错误在哪里?

我用这个命令安装了 Inertia composer require inertiajs/inertia-laravel

按照 github 页面上的说明进行操作,并将其添加@inertia到我的 app.blade.php 中,如下所示:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>
    <link rel="icon" type="image/jpg" href="{{asset("/image/logo2.png")}}">
    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>

@inertia

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

在我的登录控制器中

 public function showLoginForm()
    { …
Run Code Online (Sandbox Code Playgroud)

inertiajs laravel vue.js

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

在 RecyclerView Adapter 中的 onBindViewHolder 中获取上下文

我试图在 RecyclerViewAdapter 中以编程方式创建复选框,但我不确定如何在 onBindViewHolder 中传递上下文。另外值得注意的是我使用了 4 个不同的 ViewHolders 类。

这是我要添加复选框的 ViewHolder 类,此代码位于onBindViewHolder

ViewHolderMulChoice viewHolderMulChoice = (ViewHolderMulChoice) holder;
viewHolderMulChoice.questionNumber.setText((position + 1) + ")");
viewHolderMulChoice.questionTitle.setText(current.getQuestion());
viewHolderMulChoice.questionInstructions.setText(current.getInstruction());
if (current.getOptional() == 1) {
    viewHolderMulChoice.questionOptional.setText("*");
} else {
    viewHolderMulChoice.questionOptional.setText("");
}

List<SurveyQuestionOptions> options = current.getSurvey_question_option();
for (SurveyQuestionOptions option: options) {
    CheckBox checkBox = new CheckBox(//context goes here);
    checkBox.setText(option.getOption());
    viewHolderMulChoice.options.addView(checkBox);
}
Run Code Online (Sandbox Code Playgroud)

android

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

使用toLocaleString格式化小数,以显示2个小数和一个逗号

我正在尝试将价格格式的数字格式化为x,xxx.xx的格式,例如1,000.55,数据库中的数字是一个十进制(8,2),即1000.55,但是当我尝试在onLocaleString上使用时这个数字是行不通的。

这是我在vue中使用的功能

formatProdPrice(value) {
    return value.toLocaleString(['en-US', [{minimumFractionDigits: 2, maximumFractionDigits: 2}]]);
}
Run Code Online (Sandbox Code Playgroud)

这是我用的地方

formatProdPrice($page.price.price)
Run Code Online (Sandbox Code Playgroud)

预期的输出为1,000.55,但现在的实际输出为1000.55。我究竟做错了什么?

javascript vue.js

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

自定义 vue2-editor 工具栏

这是我用于编辑器的依赖项,他们有一个示例,他们修改默认工具栏以删除某些选项,我想删除一些选项,但该示例非常缺乏,并且没有显示如何添加所有选项我想要的选项,但我不知道如何添加它们。

这是依赖页面的示例

<template>
  <div id="app">
    <vue-editor v-model="content" :editorToolbar="customToolbar"></vue-editor>
  </div>
</template>

<script>
import { VueEditor } from "vue2-editor";

export default {
  components: {
    VueEditor
  },

  data() {
    return {
      content: "<h1>Html For Editor</h1>",
      customToolbar: [["bold", "italic", "underline"], [{ list: "ordered" }, { list: "bullet" }], ["image", "code-block"]]
    };
  }
};
</script>
Run Code Online (Sandbox Code Playgroud)

我想在我的工具栏中有这样的东西

customToolbar: [["bold", "italic", "underline"], [{ list: "ordered" }, { list: "bullet" }],
    [{ align: "left" }, { align: "center" }, { align: "right"}, { align: "justify"}],
    [{ …
Run Code Online (Sandbox Code Playgroud)

vue.js

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

标签 统计

vue.js ×4

inertiajs ×2

laravel ×2

android ×1

element-ui ×1

javascript ×1